REST: using a different field than id

Hi,

I have a simple question: When constructing restful urls with something
like

edit_user_path @user

I would like the route to be /user/username/edit instead of /user/1/edit

Now, I can do it with edit_user_path(@user.username), but i just don’t
like it.

Is there a config place that can customize the chosen field?

Thanks,

Roland

On 8 Jul 2008, at 16:18, Roland M. wrote:

edit

Now, I can do it with edit_user_path(@user.username), but i just don’t
like it.

Does overriding to_param on User to return username do the trick?

Fred

Perfect. Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs