Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
At work I am currently developing this website on ruby on rails and I got stuck. I created a form, using html but now I want to pass the data entered in the form to the Controller to save it to the db. If I used rails to create the form I know how to pass the form input to the controller, but since i used html, I dont know how to. If i did my form this way:
How would I pass the two fields to the controller, assuming I have a database called “Bookingâ€.
Thanks PS I looked at several tutorials but they only explain how to pass to the controller if you used rails to build the form.
The passed input values will be in the params hash, keyed as such. params['name'] and params['email'] will retrieve the values.
in controller u can write
Assuming u have db called Booking n table name is booking and fields are name n email.Den
def create x=Booking.new x.name=params[:name] x.email=params[:email] x.save end
