我正在使用 Rails 4 版本。我正在使用 MongoDb 作为我的项目的数据库。我想执行上传操作,因为我正在使用“回形针宝石”。我收到上述错误。实际上错误是在候选人控制器NoMethodError
中CandidatesController#create_image
。请帮我解决这个问题。
如果有任何其他方法可以上传,并且与mongoid兼容,请协助我获得解决方案。
这是我的候选人控制器操作:
def profile
@candidate = Candidate.find(params[:id])
@image = Image.new
end
def create_image
@candidate = Candidate.find(params[:id])
@image = Image.new(new_image)
@user = current_user
if @image.save
redirect_to profile_user_candidate_path(@user.id.to_s, @candidate.id.to_s)
end
end
private
def new_image
params.require(:image).permit(:logo, :candidate_id)
end
这是我的图像控制器
class ImagesController < ApplicationController
def index
@images = Images.all
end
def new
@image = Image.new
end
def show
@id = params[:id]
@image = Image.find(@id)
end
def create
@image = Image.new(params[:image])
if @image.save
redirect_to :action => :show, :id => @image.id
end
end
private
def image
params.require(:image).permit
end
end