我在rails博客应用中try 使用回形针上传时遇到了这个错误.
Paperclip::Errors::MissingRequiredValidatorError in PostsController#create
Paperclip::Errors::MissingRequiredValidatorError
Extracted source (around line #30):
def create
@post = Post.new(post_params)
这是我的控制器.rb
def update
@post = Post.find(params[:id])
if @post.update(post_params)
redirect_to action: :show, id: @post.id
else
render 'edit'
end
end
def new
@post = Post.new
end
def create
@post = Post.new(post_params)
if @post.save
redirect_to action: :show, id: @post.id
else
render 'new'
end
end
#...
private
def post_params
params.require(:post).permit(:title, :text, :image)
end
这是我的贴子助手
module PostsHelper
def post_params
params.require(:post).permit(:title, :body, :tag_list, :image)
end
end
请让我知道,如果我可以补充额外的material ,以帮助您帮助我.