Forum: Ruby on Rails link_to :post true Newbie question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
903de3fe51f14392609e28e82e1b1c6c?d=identicon&s=25 Rick Fiorentino (rickf)
on 2007-02-27 20: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,
Rick
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2007-02-27 20: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
turn
that link into a mini-form that knows nothing at all about your other
form
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.

-philip
This topic is locked and can not be replied to.