Hi all,
I’m relatively new to rails and have a question. I’ve looked through
the archives, but really have no idea what to search for so I apologize
if this has been addressed before. I am trying to use a form response
for some logic in my controller. For example, if a check box is
checked, redirect to another page. Obviously I don’t need this checkbox
to have a place in the database. But rails thinks I do. How do I have
a value in a form without having to have a place in the database for it
and without getting a “method undefined” exception?
Thanks
Bryan
Use check_box_tag instead of check_box
Fred
aust_guy wrote:
I’m relatively new to rails and have a question. I’ve looked through
the archives, but really have no idea what to search for so I apologize
if this has been addressed before. I am trying to use a form response
for some logic in my controller. For example, if a check box is
checked, redirect to another page. Obviously I don’t need this checkbox
to have a place in the database. But rails thinks I do. How do I have
a value in a form without having to have a place in the database for it
and without getting a “method undefined” exception?
Rails thinks no such thing. Add your checkbox to your view, using . Then in your controller, your value is in
params[:foo]. No database required.
If you are abusing the “scaffold” system, don’t. It’s just a one-shot
thing;
it’s not how most development should go.
–
Phlip
Redirecting... ← NOT a blog!!!