Reputation: 69
So i have this link from a partial in a view:
<td><%= link_to 'Inscribir Ejemplares en la Carrera', home_carreras_path(@race, :meeting_id => meeting.id) %></td>
That link sends me to another view where two other partials are rendered.
The browser address looks like this:
http://0.0.0.0:3000/home/carreras?meeting_id=6
So you see that the value i sent from the link is there, and i want to pass that value, that number to one of the partials rendered in that view.
i haven't found how to do that, i searched a lot before asking. So please i hope someone here can help me. Thank you.
EDIT: ADDING MORE INFO
Controller:
class HomeController < ApplicationController
def index
render :layout => 'principal'
end
def carreras
@meeting_id = params[:meeting_id]
render :layout => 'principal'
end
end
Not much action there :/
The Partial where the hidden field is:
<%= form_for(race) do |f| %>
<ul>
<% race.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.hidden_field :meeting_id %><br />
</div>
<div class="field">
<%= f.label :carrera_num %><br />
<%= f.text_field :carrera_num %>
</div>
<div class="field">
<%= f.label :caballo_num %><br />
<%= f.text_field :caballo_num %>
</div>
<div class="field">
<%= f.label :caballo_nombre %><br />
<%= f.text_field :caballo_nombre %>
</div>
<div class="field">
<%= f.label :distancia %><br />
<%= f.text_field :distancia %>
</div>
<BR>
<div class="actions">
<%= f.submit "Inscribir Ejemplar" %>
</div>
<% end %>
Upvotes: 0
Views: 73
Reputation: 4088
If your controller actions for carreras
, you can set an instance variable for the meeting_id.
def carreras
@meeting_id = params[:meeting_id]
# rest of controller action
end
@meeting_id
will then be available to you throughout your rendered action.
You can supply your hidden_field
tag with an options hash to set the value.
<%= hidden_field :meeting_id, value: @meeting_id %>
Upvotes: 1