I have a model submission and a nested model attachment
in submission.rb:
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets, :allow_destroy => true
in assets.rb :
attr_accessible :file_id, :attachment
belongs_to :submission
has_attached_file :attachment
in my submission controller:
def new
@submission = Submission.new
@asset = 2.times{ @submission.assets.build }
respond_to do |format|
format.html # new.html.erb
format.json { render json: @submission }
end
end
def edit
@submission = Submission.find(params[:id])
@asset = 2.times{ @submission.assets.build }
end
And I’m getting a unknown attribute: submission_id error.
What could possibly be wrong here.
I’m following the screencast here:
http://www.emersonlackey.com/article/rails-paperclip-multiple-file-uploads
Seems submission_id is not present in your assets table.
You have to generate asset model like:
And then run: