Skip to content

Instantly share code, notes, and snippets.

@rbeene
Created July 30, 2010 16:35
Show Gist options
  • Save rbeene/500847 to your computer and use it in GitHub Desktop.
Save rbeene/500847 to your computer and use it in GitHub Desktop.
#controller
def new
@ad = Ads::Ad.new
@ad.build_our_location
3.times {@ad.channel_groups.build}
end
#form section
<% form.fields_for :channel_groups do |f| %>
<%= f.select :channel_group_id, ChannelGroup.main_channel_groups.collect {|c| [c.name, c.id]}, {:include_blank => true }, :label => "Genre"%>
<% end -%>
# model
has_many :channel_groups, :class_name => "Ads::ChannelGroup"
accepts_nested_attributes_for :channel_groups, :reject_if => lambda { |a| a[:channel_group_id].blank? }
belongs_to :our_location
accepts_nested_attributes_for :our_location
#error
Ads::ChannelGroup(#2202352280) expected, got Array(#2148392460)
# params
Parameters: {"ad"=>{"advertisable_id"=>"38140", "body"=>"fdsaf", "advertisable_type"=>"Events::Event", "headline"=>"fdsa", "utc_end_time"=>"August 7, 2010", "utc_start_time"=>"July 22, 2010", "channel_groups"=>{"channel_group_id"=>"4"}, "our_location"=>{"city"=>"New York", "country"=>"US", "state"=>"NY"}}, "authenticity_token"=>"3klvrEBk9VHhJRsITURoTT76isaHuFfsYbf+taWZkDw=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment