Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert How to pass form input to the ...

Replytotopic

How to pass form input to the controller

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 0
Sign in to rate this post

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:
<form name="reservation">
<input name="name" id="name">
<input name="email" id="email">
</form>

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.

 
Me

Authority 62
Posting Rating 78
Sign in to rate this post

The passed input values will be in the params hash, keyed as such. params[‘name’] and params[‘email’] will retrieve the values.

 
Profile

Authority 0
Posting Rating 0
Sign in to rate this post

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

 
Profile

Authority 0
Posting Rating 0
Sign in to rate this post

thanks

Replytotopic

Other Recent Topics

Ask a Rails expert : nested application ApplicationController get called intead of children::ApplicationController

Ask a Rails expert : Best way to structure a database for a large/static dataset

Ask a Rails expert : Ruby Developer (ROR) - Scottish based (Remote working from within the UK)

Ask a Rails expert : Above Ground Pool Supplies

Ask a Rails expert : How to get url params in observer or model in Rails 3.1

Ask a Rails expert : What can persuade you to hire Junior Ruby devs with significant PHP experience?

Ask a Rails expert : What industry value does the Ruby or Rails Certification currently have?

Ask a Rails expert : Louis Vuitton Damier Azur Canvas specially sale ( www.salecheaplouisvuitton.com )

Ask a Rails expert : ·How to check errors/puts statements from ruby files which are under cronob

Ask a Rails expert : Louis Vuitton cheap Soft Sided Luggagespecial offer( www.salecheaplouisvuitton.com )

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel