i am very new to ror and i want to create a page which does the
following:
The user can register(devise) and can specifiy a page name e.g.
jondoe. After this his account is send by email etc.
Now I want to generate a page which follows the following route:
www.mydomain.com/jondoe
What I understood is that the ror standard routing goes /controller/
action but of course I dont have a controller called jondoe.
I also want to have the router for creating a user or doing something
else via urlwww.mydomain.com/user/edit
I know this questions could be stupid but I didnt found a way to solve
this issue. Can somebody give me a hint?
Two things:
You don't have to stick with the defaults, if you want action/
controller, action/id/controller, randomword/action etc.. then just go
ahead.
You can also have wildcards in the paths you match, which sounds like
what you want
The docs for ActionController::Routing (or ActionDispatch::Routing)
have plenty of examples. There's also a guide on routing (http://
guides.rubyonrails.org/routing.html)
> > i am very new to ror and i want to create a page which does the
> > following:
When I have a little, but very important advice for you: try to use
resources and the REST design.
> > The user can register(devise) and can specifiy a page name e.g.
> > jondoe. After this his account is send by email etc.
> > Now I want to generate a page which follows the following route:
> >www.mydomain.com/jondoe
There is a very good recipe for this kind of things: Please check
Rails Recipes book [Make Your URLS Meaningful (and Pretty)]
Most likely you will need something like this:
map.connect ':user', :controller => 'users', :action =>
'show', :filter => 'user'
Hi Ivan, I inserted now the above mentioned line but I am getting now
the following error:
/config/routes.rb:8:in `block in <top (required)>': undefined local
variable or method `map' for #<ActionDispatch::Routing::Mapper:
0x3eba8b0> (NameError)