I’m working on building an app that can log and edit phone call
information. I’ve got the creating and editing parting working great,
and I’ve started an attempt to add searching. I can’t seem to figure
out how to get an [:id] parameter from a form and passed between two
controller methods. Right now I have a web page with a single text
field in it and a button. I want to be able to type in a valid record
ID into the text field, hit the button and be taken to the edit page for
the record with that ID. I realize this should be dead simple, but I
haven’t figured out a way to get it to work. I keep getting an error:
"Unable to find without an ID. Hopefully someone here can tell me where
I’ve gone astray. Here is the code I have right now:
##controller.rb
def edit @support_call = SupportCall.find(params[:id])
end
Wow! You guys were really fast!. Thanks everybody. Your suggestions got
everything working correctly. It’s great to know that a helpful
community like this is available. I’ll try to have a more challenging
problem next time I need help
You can use this
<%= start_form_tag :action => “edit”%>
When the user clicks the button the browser will automatically wrap up
any
forms you have and post them back to the action you’ve defined. (In this
case “edit”)
In the edit action in your controller you can pull out the data from
this
form like
params[:support_call][:id]
As the previous email illustrates.
-Brian
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.