I am using Rails 2.3.8. I have a view with a list of mobile carriers. I
want to assign a country to each mobile carrier. I do this by having a
drop down list with available countries for the user to select.
This is my form:
<table>
<tbody>
<% form_for :HhActiveCarrier, @carriers, :url => { :action => "update"
} do |f| %>
<% for carrier in @carriers %>
<tr>
<%= render :partial => "summary_detail", :locals => {:carrier =>
carrier, :f => f} %>
</tr>
<% end %>
</tbody>
</table>
<%= submit_tag "Update" %>
<% end %>
With my partial:
<td class="tn"><%= h(carrier.name.to_s()) -%></td>
<td class="sc"><%= h(carrier.country.to_s()) -%></td>
<td class="sc"><%= select(:carrier, "country", @countries) -%></td>
This is the controller where I define the variables:
class ActiveCarriersController < ApplicationController
def index
@carriers = HhActiveCarrier.find(:all)
for carrier in @carriers
country = carrier["country"]
if country.nil?
carrier["country"] = "none"
end
end
@countries = ["USA", "UK", "Canada"]
end
def update
carrier = HhActiveCarrier.find(params[:name])
redirect_to( :action => "index" )
end
When I click the "Update" button, I want to have the "country" of each
HHActiveCarrier to be set. Right now this is the error I get:
Couldn't find HhActiveCarrier without an ID
How do I solve this problem? Thanks.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.