Ruby on rails 升级到rails 4,无法再注册用户

Ruby on rails 升级到rails 4,无法再注册用户,ruby-on-rails,carrierwave,Ruby On Rails,Carrierwave,我升级到rails 4,现在我无法再在我的应用程序上注册用户。看来我的画廊(CarrierWave)坏了。我已经检查了代码,现在没有发现任何会阻止它工作的东西。我得到一个未定义的方法“gallers”,它指向def setup_gallery:self.galleries 0?对:错 结束 def未读消息 已接收\u消息。其中('read\u at为NULL') 结束 def已发送消息 消息。由(自身)发送 结束 #返回此用户的未读邮件数 def未读邮件数 eval'messages.count

我升级到rails 4,现在我无法再在我的应用程序上注册用户。看来我的画廊(CarrierWave)坏了。我已经检查了代码,现在没有发现任何会阻止它工作的东西。我得到一个未定义的方法“gallers”,它指向def setup_gallery:self.galleries 0?对:错 结束 def未读消息 已接收\u消息。其中('read\u at为NULL') 结束 def已发送消息 消息。由(自身)发送 结束 #返回此用户的未读邮件数 def未读邮件数 eval'messages.count(:conditions=>[“recipient_id=?AND read_at IS NULL”,self.user_id])” 结束 美国国防部;用户名 结束 def具有角色?(角色名称) 角色、当前?&role.to_sym==role_name.to_sym 结束 def发送密码重置 生成\u令牌(:密码\u重置\u令牌) self.password\u reset\u sent\u at=Time.zone.now 拯救 UserMailer.password\u重置(self.deliver) 结束 def生成_令牌(列) 开始 self[column]=SecureRandom.urlsafe_base64 用户存在时结束?(列=>self[column]) 结束 私有的 def设置库 自助画廊“新” 结束 结束 定义编辑 @photo=photo.find(id_参数) 结束 def更新 @photo=photo.find(id_参数) 如果@photo.update_属性(photo_参数) flash[:notice]=“已成功更新照片。” 将_重定向至@photo.gallery 其他的 呈现:操作=>“编辑” 结束 结束 def销毁 @photo=photo.find(id_参数) @照片。销毁 闪光 [:注意]=“已成功销毁照片。” 将_重定向至@photo.gallery 结束

私人的

def用户参数 参数require(:user).permit(:name) 结束

def id_参数 参数require(:id).permit(:name) 结束
结束

经过反复试验,我发现我必须更改用户模型中的私有方法

起作用的是

 Gallery.create(user: self)

感谢那些响应帮助的人

你检查过这个了吗?好的,我用强参数更新了上面的用户控制器。现在,当我注册时,它会将我重定向到主页,错误来自表单,密码不能为空,电子邮件无效。这与强参数无关,因为错误消息在控制器外部。如果您使用Desive进行注册,请检查此项,因为没有Desive。也许我做错了强参数?我更新了代码仔细查看日志。是否有“无法批量分配受保护的属性…”的消息(该消息在所有其他日志条目中很容易丢失)。如果存在这样一条消息,那么它肯定是一个强参数问题,并且消息应该确切地指定导致问题的属性。
# models/user.rb
  after_create :setup_gallery

  def received_messages
      Message.received_by(self)
    end

 def unread_messages?
   unread_message_count > 0 ? true : false
 end

 def unread_messages
   received_messages.where('read_at IS NULL')
 end

 def sent_messages
   Message.sent_by(self)
 end

 # Returns the number of unread messages for this user
 def unread_message_count
   eval 'messages.count(:conditions => ["recipient_id = ? AND read_at IS NULL", self.user_id])'
 end

  def to_s; username
  end

  def has_role?(role_name)
    role.present? && role.to_sym == role_name.to_sym
  end

  def send_password_reset
    generate_token(:password_reset_token)
    self.password_reset_sent_at = Time.zone.now
    save!
    UserMailer.password_reset(self).deliver
  end

  def generate_token(column)
    begin
      self[column] = SecureRandom.urlsafe_base64
    end while User.exists?(column => self[column])
  end

  private
  def setup_gallery
     self.galleries << Gallery.create
   end
end
class PhotosController < ApplicationController

  def new 
    @photo = Photo.new
  end

  def create
    @photo = Photo.new(photo_params)
    @photo.user = current_user
    if @photo.save
      flash[:notice] = "Successfully created photos."
      redirect_to :back
    else
      render :action => 'new'
    end
  end

  def edit
    @photo = Photo.find(id_params)
  end

  def update
    @photo = Photo.find(id_params)
    if @photo.update_attributes(photo_params)
      flash[:notice] = "Successfully updated photo."
      redirect_to @photo.gallery
    else
      render :action => 'edit'
    end
  end

  def destroy
    @photo = Photo.find(id_params)
    @photo.destroy
    flash
 Gallery.create(user: self)