Forum: Ruby on Rails link_to :post true Newbie question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rick F. (Guest)
on 2007-02-27 21:43
Hi All,

I am attempting to use a link_to helper to perform a form post using the
following construct:

<%= link_to 'Save', {:action =>'create'}, :post => true %>

What I find is the parameters passed to the webserver are empty. My
model validation stuff triggers indicating the fields in question are
empty too. This is to create a new DB entry so no ID is being passed,
although there are a few required parameters obviously.

This works fine if I use:

<%= submit_tag "Create" %>

So do I need to specify the parameters as part of the link_to?

ROR 1.2.2

Any help is appreciated,
Philip H. (Guest)
on 2007-02-27 21:49
(Received via mailing list)
> This works fine if I use:
> <%= submit_tag "Create" %>

View the source of your page.  Using link_to with :post => true will
that link into a mini-form that knows nothing at all about your other
on the site.

If you don't want an actual submit button, then you'll need to use
link_to_function and set the function to do document.myform.submit() or
some such.

This topic is locked and can not be replied to.