我在我的视图中有以下循环:
<% @posts.each do |post| %>
<%= link_to post do %>
Some html
<% end %>
<% end %>
以上代码将生成链接:localhost:3000/posts/sdfsdf-sdfsdf
但我希望链接为:localhost:3000/sdfsdf-sdfsdf
以下是我的路由:
resources :posts, except: [:show]
scope '/' do
match ':id', to: 'posts#show', via: :get
end
resources :posts, path: ""
,这是唯一的方法,对吗? - Prabhakaran