0
未定義のメソッド `ペーパークリップ::添付ファイルのために」を作成:0x007f33ecb3bd30
campings_controller.rb
def create
@camping = Camping.new((camping_params).merge(:user_id => current_user.id))
respond_to do |format|
if @camping.save
format.html { redirect_to @camping, notice: 'Camping was successfully created.' }
format.json { render :show, status: :created, location: @camping }
else
format.html { render :new }
format.json { render json: @camping.errors, status: :unprocessable_entity }
end
end
end
def update
@camping = Camping.find(params[:id])
if params[:image]
params[:image].each do |image|
@camping.create(image: image)
end
end
end
_edit.html.erb
<%= file_field_tag "image[]", type: :file, multiple: true %>
camping.rb
has_attached_file :image, default_url: "/images/missing.jpg"
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]