Forum: Ruby on Rails params

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.
guest (Guest)
on 2007-06-20 10:37
Hallo
I have the Problem that i give a parameter from the the Controller to
the view and then i want to give back that Parameter from the view to
the controller! But it doesn't work. Please can somebody help me!

<% form_tag :action => :create do %>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td width="100" height="36">Bezeichnung</td>
      <td><%= text_field_tag :name, params[:name], :size => 40 %></td>
      <%=:id => @house.id, params[:id], size => 0%>
      <td><%= submit_tag "Hinzufügen" %></td>
    </tr>
  </table>
<%end%>

In this code i want to give back @house.id from the view to the
controller!

Thank you

Harald
Wouter de Bie (Guest)
on 2007-06-20 10:41
You should use a hidden_tag for this. "Giving back to the controller" is
done by posting http data to the controller.
guest (Guest)
on 2007-06-20 10:54
<% form_tag :action => :create do %>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td width="100" height="36">Bezeichnung</td>
      <td><%= text_field_tag :name, params[:name], :size => 40 %></td>
      <%= hidden_tag :id => @house.id, params[:id]%>
      <td><%= submit_tag "Hinzufügen" %></td>
    </tr>
  </table>
<%end%>

Thanks for your fast reply but when i use this hidden_tag i get an
error! Can somebody please show me how it works!

THANK you

Harald
guest (Guest)
on 2007-06-20 11:47
Hallo

Please can somebody show me how it works!

THANKS
guest (Guest)
on 2007-06-20 12:55
Hallo

I have solved my Problem but i have a Question. Is it possible to give
with the redirect_to also Parameters?

THANK
This topic is locked and can not be replied to.