How to remove model name from URL with friendly_id in ruby on rails
friendly-id, rails-routing, ruby-on-rails, ruby-on-rails-4, url-routing
Solution
in routes.rb
resources :questions, path: ''
throws errors when you are logged out.
try:
get '/:friendly_id', to: 'questions#show'
Problem
I have a question model which allows users to add questions. I have set up Friendly_id so now that when a user adds a question the url is: ``` http://localhost:3000/questions/this-is-a-question ``` However, i want the url to appear like this ``` http://localhost:3000/this-is-a-question ``` Do you have any ideas on how i can do this with friendly_id? Thanks UPDATE: This is my friendly_id bit in question.rb ``` extend FriendlyId friendly_id :title, use: [:slugged, :finders] def slug_candidates [ :title, [:title, :id] ] end def should_generate_new_friendly_id? new_record? end ``` end