Reputation: 8730
How to send parameter in render a view from action
respond_to do |format|
if @donation.save
else
format.html { render :new,:locals => { :need_id => @need_id }}
end
end
But need_id
is accessble in new.html.erb
How I pass this param?
Upvotes: 0
Views: 261
Reputation: 88
If you have @need_id in the controller and this
format.html { render :new,:locals => { :need_id => @need_id }}
you can do <%= need_id %> in view file.
Upvotes: 0
Reputation: 4920
If you have already defined @need_id
in your controller. It will be available in the corresponding view files as it is:
View file (.html.erb):
<%= @need_id %>
Upvotes: 1