Topic: Taking information from a form and putting into a restful post

I need to have a form on the view so that the user can input which username he wants to post the facebook message to.

Right now in the post action I just have username=name. But the name variable has to be taken from the form.

How do I do that?

It's probably very easy just new to rails


<td><%= link_to 'Post', "/facebook/fbpostsetup/?id="+add.id.to_s+"&username=name" , class: "btn btn-small btn-primary" %></td>

Thanks for your help

Re: Taking information from a form and putting into a restful post

I don't see where you are setting up[ your form and you seem to be using a link rather than a button to send an HTTP POST or HTTP PUT request back to the server which is a big No No in web development,  You don;t really want bots clicking links that will send data!

I would set up a form using form_for or form_tag, attach any fields you want to the form and then just add a submit button to the form, that way whatever data is filled in by the user will automatically get sent back in the params hash to the relevant controller and action as determined by the parameters that you use in the form declaration.

See here for more details http://apidock.com/rails/ActionView/Hel … r/form_for

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)