Hallo Liste,
habe hier folgende Konstellation:
service.rb
has_many :definitions
has_many :metrics, :through => :definitions
metric.rb
has_many :definitions
has_many :services, :through => :definitions
definition.rb
belongs_to :metric
belongs_to: service
In der edit/new view für einen Service möchte ich gerne eine liste von
check_boxes, so dass ich auswählen kann, welche metrics zum Service gehören.
Bisher habe ich es so versucht:
<% for metric in Metric.all %>
<%= check_box_tag "service[metrics][]", metric.id,
@service.metrics.include?(metric) %>
<%=h metric.label %><br />
<% end %>
Aber ich bekomme folgende Fehlermeldung, nachdem ich das (edit) Formular
abgeschickt habe:
Processing ServicesController#update (for 127.0.0.1 at 2010-04-13 16:13:28)
[PUT]
Parameters: {"commit"=>"Create", "service"=>{"name"=>"AAA", "label"=>"aaa",
"metrics"=>["3"]}, "id"=>"1"}
Service Load (0.2ms) SELECT * FROM "services" WHERE ("services"."id" = 1)
ActiveRecord::AssociationTypeMismatch (Metric(#2182532020) expected, got
String(#2148312060)):
app/controllers/services_controller.rb:63
app/controllers/services_controller.rb:62:in `update'
Habt ihr eine Idee? Gruss, Jürgen
_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/listinfo/rubyonrails-ug