Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 设计无密码的更新资源_Ruby On Rails_Devise - Fatal编程技术网

Ruby on rails 设计无密码的更新资源

Ruby on rails 设计无密码的更新资源,ruby-on-rails,devise,Ruby On Rails,Devise,所以我一直在寻找一种方法来做到这一点,我发现 资源。如果目标只是更新某些用户属性,则在不使用密码的情况下更新。但我正在尝试更新订阅信息(如信用卡详细信息),这些信息将发送到 我该怎么做 相关代码: class RegistrationsController < Devise::RegistrationsController before_filter :configure_permitted_parameters def update super if params

所以我一直在寻找一种方法来做到这一点,我发现
资源。如果目标只是更新某些用户属性,则在不使用密码的情况下更新。但我正在尝试更新订阅信息(如信用卡详细信息),这些信息将发送到

我该怎么做

相关代码:

class RegistrationsController < Devise::RegistrationsController
  before_filter :configure_permitted_parameters
  def update
    super
    if params[:product]
        if resource.create_and_subscribe(params[:product])
            if resource.active_for_authentication?
                set_flash_message :notice, :signed_up if is_navigational_format?

                subscription = resource.subscription
                if subscription
                    SubscriptionMailer.signup_success(subscription).deliver
                end
            else
                set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
                expire_session_data_after_sign_in!
                respond_with resource, :location => after_inactive_sign_up_path_for(resource)
            end
        end
    end
end

这就是我如何设置我的用户模型,以便在没有密码的情况下更新用户

#app/models/user.rb

  attr_accessor :updating_password
  def should_validate_password?
      updating_password || new_record?
  end
现在,在我的控制器中,我会检查密码是否已提交

#app/controllers/users/users_controller.rb
  before_filter :check_password_submitted, :only => :update
  def check_password_submitted
    if params[:user][:password].blank?
      params[:user].delete("password")
      params[:user].delete("password_confirmation")
      user.updating_password = false
    else
      user.updating_password = true
    end
  end
我希望这会有所帮助
快乐编码

这就是我如何设置我的用户模型,以便在没有密码的情况下更新用户

#app/models/user.rb

  attr_accessor :updating_password
  def should_validate_password?
      updating_password || new_record?
  end
现在,在我的控制器中,我会检查密码是否已提交

#app/controllers/users/users_controller.rb
  before_filter :check_password_submitted, :only => :update
  def check_password_submitted
    if params[:user][:password].blank?
      params[:user].delete("password")
      params[:user].delete("password_confirmation")
      user.updating_password = false
    else
      user.updating_password = true
    end
  end
我希望这会有所帮助
快乐编码

你能找出问题的代码吗?你能找出问题的代码吗?