Forum: Ruby on Rails Form actions with additional parameters

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.
5e518814b76962fdd1ad0e74dfac5ea7?d=identicon&s=25 Martin Gamsjaeger (Guest)
on 2006-05-18 03:35
(Received via mailing list)
Hiall,

I want to give the action of a form an additional parameters but can't
figure out how to do it. My code looks like this

<%= start_form_tag :action => 'create', next_step => true %>
    <%= render :partial => 'user_form' %>
    <%= render :partial => 'community_form' %>
    <%= submit_tag "Optional Next Step" %>
<%= end_form_tag %>

<%= button_to 'Skip Next Step', :action => 'create', next_step => false
%>

The form_tag should demonstrate what I intend to do. In the
corresponding 'create' action of my controller, I want to redirect_to
different locations depending on params[:next_step], but somehow
params[:next_step] is never present, and I always end up being
redirected to the 'Skip next Step' action,

Any ideas?

cheers
Martin
43ec5998360a0cc21b51afef1781e9c0?d=identicon&s=25 Daniel Higginbotham (danieldaniel)
on 2006-05-18 03:47
(Received via mailing list)
Howdy Martin,

The first argument of start_form_tag can be a hash of options for
url_for-
try something like

<%= start_form_tag {:action => 'create', :id=whatever,
:param3="community_farm"}, next_step => true %>

I hope this helps!
5e518814b76962fdd1ad0e74dfac5ea7?d=identicon&s=25 Martin Gamsjaeger (Guest)
on 2006-05-18 04:48
(Received via mailing list)
After reading apidoc I am convinced that passing arguments for urls
should work with form_tag. I tried the following:

<%= start_form_tag({:action => 'create'}, {}, :create_webca => true) %>

and it also gives me no parameters for the url ... I can't figure out
what I'm doing wrong

Any help VERY much appreciated!
Martin
9d1f5d2d9de70bd9a934f557dc95a406?d=identicon&s=25 Daniel ----- (liquid)
on 2006-05-18 04:54
(Received via mailing list)
Hi Martin.

Your inclusion of next_step => true should be  :next_step => true

ie, the option key should be a symbol.
The call should be made (I think) as follows.  I'm at work and have no
ruby
here :(

start_form_tag :url => { :action => 'create', :next_step => true }
5e518814b76962fdd1ad0e74dfac5ea7?d=identicon&s=25 Martin Gamsjaeger (Guest)
on 2006-05-18 05:04
(Received via mailing list)
Hi Daniel,

Thx for the tip, we're almost getting there :-) Your proposed
statement leads to the following html output:

<form action="/admin/community/new?url=next_steptrueactioncreate"
method="post">

close but not quite there, if only it weren't so late already where I
live :)
5e518814b76962fdd1ad0e74dfac5ea7?d=identicon&s=25 Martin Gamsjaeger (Guest)
on 2006-05-18 05:13
(Received via mailing list)
Thx for the replies guys! I could swear I tried that before, maybe I
didn't reload properly, back button is too much a habit :)

This works (like Daniel suggested the key option should be a symbol)

<%= start_form_tag :action => 'create', :create_webca => true %>

Thx for your patience :)

cheers
Martin
5e518814b76962fdd1ad0e74dfac5ea7?d=identicon&s=25 Martin Gamsjaeger (Guest)
on 2006-05-18 05:19
(Received via mailing list)
Me again :)

Funny enough, this doesn't give me the expected parameter

<%= button_to 'Skip next step', :action => 'create', :create_webca =>
false %>

Yes, I got the one with the back button right :) Now I'm actually
wondering if it wasn't about the back button in the beginning. ???
This topic is locked and can not be replied to.