def create
@author = User.find(current_user)
pub_params = params[:publication]
##
#bcids = pub_params['categorizations_attributes']['0']['book_category_id']
#pub_params.delete('categorizations_attributes')
#pub_params['categorizations_attributes'] = Hash.new()
#bcids.each_with_index do |i, bcid|
# if i.to_i > 0
# pub_params['categorizations_attributes'][i] = Hash.new()
# pub_params['categorizations_attributes'][i]['book_category_id'] = bcid
# end
#end
@publication = @author.publications.new(pub_params)
#setup_sti_model
respond_to do |format|
if @publication.save
format.html { redirect_to @publication, notice: 'Publication was successfully created.' }
format.json { render json: @publication, status: :created, location: @publication }
else
format.html { render action: "new" }
format.json { render json: @publication.errors, status: :unprocessable_entity }
end
end
end
# PUT /publications/1 # PUT /publications/1.json
每当我尝试添加新出版物时,我都会收到此错误。