It's been a while since I did this in Rails, but in Merb it looks something
like this:
Controller:
class Site < Application
def my_method
return params[:id]
end
end
Router:
match("/:id").to(:controller => "site", :action => "my_method
").name(:site_my_method)
You have my make sure that the router definition is first (or at least
before anything else that would match /erik.
Hope that helps,
Chris
On Sun, Oct 25, 2009 at 8:26 AM, Erik Pukinskis <[email protected]>wrote:
>
> This is a bit of a head scratcher, I'm hoping some of the rails
> magicians out there can help.
>
> I've got a users controller, and users have usernames, and I want the
> url for users to be just their username at the root of the tree. So
> ...
>
> /erik => {:controller => "users_controller", :action => "show", :id =>
> "erik"}
> /erik/edit => {:controller => "users_controller", :action => "edit",
> :id => "erik"}
>
> ... and so-on. But I can't figure out how to write the route for
> this. Obviously I could connect up every single action individually,
> but there should be a way to do this with resources, no? The closest
> I can get is:
>
> map.resources :users, :as => ''
>
> ... but that maps the erik user to //erik. Not quite right.
>
> Thanks for the help! This one is driving me a little batty. And
> while I'm at it... can anyone recommend a good essay or book chapter
> on routes, paths, and such? It's still all a bit magical to me.
>
> Erik
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---