Existence of params[:id]

ok, i’m sure I have forgotten or missing something, i hope you guys
can help:

if a user types :controller/edit/1, then he gets to edit the object
with the :id of 1.

If he only types in :controller/edit I want it to redirect him
somewhere else.

How do I test for the existence of params[:id] in an if statement. Or
is there a better way to accomplish this?

Thanks

Anthony wrote:

ok, i’m sure I have forgotten or missing something, i hope you guys
can help:

if a user types :controller/edit/1, then he gets to edit the object
with the :id of 1.

If he only types in :controller/edit I want it to redirect him
somewhere else.

How do I test for the existence of params[:id] in an if statement. Or
is there a better way to accomplish this?

Thanks

Well, assuming that your routes.rb file is set up the way it should you
should be able to get at the :id in your controller, that is unless you
have some kind of filter at work in your controller. But to test for the
existence of :id use params[:id[.blank? or params[:id].nil?

-S

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