rails remove controller path from the url
I have the following loop in my view <% @posts.each do |post| %> <%= link_to post do %> Some html <% end %> <% end %> The above code will generate link as localhost:3000/posts/sdfsdf-sdfsdf But I would like to have the link as localhost:3000/sdfsdf-sdfsdf Here is my route resources :posts, except: [:show] scope '/' do match ':id', to: 'posts#show', via: :get end You could do this: #config/routes.rb resources :posts, path: "" #-> domain.com/this-path-goes-to-posts-show -- Also, make sure you put this at the bottom of your routes; as it will override any preceding routes. For example, domain.com