My models:
class Country < ActiveRecord::Base
has_many :regions
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets
end
class Region < ActiveRecord::Base
belongs_to :country
has_many :appartments
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets
end
class Asset < ActiveRecord::Base
belongs_to :region
belongs_to :country
has_attached_file :image,
:styles => {
:thumb=> “100x100>”,
:small => “300x300>”,
:large => “600x600>”
}
end
The region _form
<% form_for([@country, @region]) do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :content %>
<%= f.text_area :content %>
<%= f.fields_for :assets do |asset| %>
<% if asset.object.new_record? %>
<%= asset.file_field :image %>
controller:
@country = Country.find(params[:country_id])
@region = @country.regions.find(params[:id])
5.times { @region.assets.build }
When uploading an image only the region_id is filled in and not the
paperclip attributes.
What i am doing wrong?
Grtz…remco