ruby - Rails URL question -
if have users model, , individual user, say, person1, there way have url: www.myapp.com/person1
show www.myapp.com/users/person1
would? called?
thank you!
you should define route in routes.rb
file:
match "/:user" => "users#show"
and you'll username given in params[:user]
. need know kind of route override other routes defined, because match string, should @ least define constraints on username.
for example if usernames matches regexp define constraint
match "/:user" => "users#show", :constraints => { :user => /some-regexp/ }
and don't forget set route last 1 in routes file, otherwise clash sure other routes.
read this full reference
Comments
Post a Comment