画像を投稿することでこのエラーが出てしまいます。
<div class="form uk-width-1-2"> <%= form_for(@post) do |f| %> <%= f.hidden_field :ken_id, value: "hoge" , class:"kenid"%> <%= f.text_area :content , placeholder: "都道府県を選択してください", class:"uk-textarea" %> <%= text_field_tag 'post[tag_list]', @post.tag_list, placeholder: "タグを#区切りで入力", class:"form-control" %> <%= f.file_field :image %> <%= f.submit "post" , class:"uk-button" %> <% end %> </div>
class
1 before_action :authenticate_user! 2 3 def new 4 @post = Post.new 5 end 6 7 def create 8 @post = current_user.posts.build(post_params) 9 @user_ken = current_user.user_ken.build(ken_id:params[:post][:ken_id]) 10 11 if @post.save && @user_ken.save 12 flash[:success] = "ポストが作成され行った県状態にしました" 13 redirect_to ken_path(@post.ken_id) 14 else 15 flash[:danger] = "ポストが作成されませんでした" 16 redirect_to home_pages_index_url 17 end 18 19 end 20 21 def destroy 22 @post = Post.find_by(id: params[:id]) 23 @post.destroy 24 flash[:success] ="ポストを削除しました" 25 redirect_back(fallback_location: root_path) 26 end 27 28 private 29 30 def post_params 31 params.require(:post).permit(:ken_id, :content, :tag_list, :image) 32 end 33 34 35end
画像が保存されなくなりました。
調べたのですがわからず助けてもらえると幸いです。
よろしくお願いします。
userのschemeとmodelの情報がないと判断難しいかと、、
あなたの回答
tips
プレビュー