So I have my table users and each record has a username field
and I have my root to controller main and action `index
root :to => 'pages#main'
so if go to http://mydomain.com It’ll show my main#index page and i have the about and contact pages as well.
but if i go to http://mydomain.com/Mr_Nizzle it shows me the page of the user Mr_Nizzle which is on users#show (just like example) and as well for the other users to show every user’s page…
is it right if i go =>
match ':username' => 'users#show'
match 'contact_us' => 'main#contact'
match 'about' => 'main#about'
root :to => 'pages#main'
so i can leave all the logic on route instead of in the main controller?
Thanks.
I’m not sure exactly what your asking, however this may be of some help. I think (at least for about and contact) the correct syntax is
match '/contact_us' => 'main#contact(the same for about but replace contact with about), theroot :to => 'pages#main'is correct (that’s the same as doing match ‘/’ => ‘pages#main’)What are you asking about the
match ':username' => 'users#show'? Do you want (for example) a url to be http://mydomain.com/users_username ? Where users_username is the name of the user’s profile that they are navigating to? If so, i think you can do something likematch '/:username' => 'users#show'but i’m not entirely sure.Get back to me on what works and what doesn’t