画像アップロードの gem refile利用し、データ登録をしようとしています。
その際に登録フォームから送信した際にparam is missing or the value is emptyとなります。
これはストロングパラメーターの設定でのエラーと認識しているのですが、controller上では
問題ないはずなのですが、エラーが発生するので、どなたか解決策をご教授頂ければと存じます
view
= simple_form_for(@article, url: articles_path) do |f| = f.input :title = f.attachment_field :eyecatch_id = f.input :content = f.input :publish_time = f.submit "送信"
model
class Article < ActiveRecord::Base attachment :eyecatch_id end
controller
def new @article = Article.new end def create @article = Article.new(article_params) if @article.save redirect_to new_article_path else render 'new' end end private def article_params params.require(:articles).permit(:title, :content, :publish_time, :eyecatch_id) end
コンソール上でのエラー
Parameters: {"utf8"=>"✓","authenticity_token"=>"fU0OTHuvJwjSwKZNk3F1Wgpit3Hmi49OW0wbc6lNDGSklZbiLJdc362gwc77nxxdWHZ0kdTWtSIHHXSqju+HXg==", "article"=>{"title"=>"だあ", "eyecatch_id"=>#<ActionDispatch::Http::UploadedFile:0x007ff9412ce7b8 @tempfile=#<Tempfile:/var/folders/4v/dsv8p_992w1f1f5bjqfwrp2h0000gn/T/RackMultipart20170814-25773-1ioadl.jpeg>, @original_filename="プロフィール.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"article[eyecatch_id]\"; filename=\"\xE3\x83\x95\xE3\x82\x9A\xE3\x83\xAD\xE3\x83\x95\xE3\x82\xA3\xE3\x83\xBC\xE3\x83\xAB.jpeg\"\r\nContent-Type: image/jpeg\r\n">, "content"=>"だあ", "publish_time(1i)"=>"2017", "publish_time(2i)"=>"5", "publish_time(3i)"=>"18", "publish_time(4i)"=>"13", "publish_time(5i)"=>"11"}, "commit"=>"送信"} Completed 400 Bad Request in 2ms (ActiveRecord: 0.0ms) ActionController::ParameterMissing (param is missing or the value is empty: articles): app/controllers/articles_controller.rb:33:in `article_params' app/controllers/articles_controller.rb:12:in `create'
image magick
Version: ImageMagick 6.9.3-0 Q16
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/15 13:14