url - Ruby on Rails generate routing -


i trying generate routes in rails app. app has movie table , column genre. want make routes this: /movies-genre-horror , shows movies genre horror. possible? if yes, can give hint how it? nice if there's tutorial it. did make this: /movies/genre/horror , works. use gem friendly_id , use slug change genre not url friendly.

add default route routes.rb. @ end

match ":default" => "foo#default" 

and inside foo_controller.rb

def default   # here params   parts = params[:default].split("-")   controller = parts[0]   action = parts[1]   genre = parts[2]   records = movie.where(genre: genre)   if records.count > 0     # redirect controller aciton   else     raise actioncontroller::routingerror.new('not found')   end end 

it's not tested, think should point.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -