Milia确认网址无法在Rails中使用

时间:2016-06-18 00:07:22

标签: ruby-on-rails ruby git

我正在研究由Mashrur教授的Udemy的完整Ruby on Rails开发人员课程。我在SaaS App Project的第241节第241课中工作。运行代码并注册我的应用程序后,我尝试了我的确认网址,但它没有工作。我通过confirmmations_controller.rb文件中的代码返回并清理了一些内容。然后我重新将更改重新发送到git并推送代码。在这之后,我无法生成新的确认网址以确认我的注册。我该如何解决这个问题?

在我的确认中,这是我收到的http://https//completerubyonrailscourse.ide.c9.io:3000/users/confirmation?confirmation_token= ...

我很困惑为什么我的网址以"http://https//"开头。是因为我在云计算中工作吗?您是否能够了解发生这种情况的原因?

应用程序/控制器/ confirmations_controller.rb:

class ConfirmationsController < Milia::ConformationsController
  def update
    if @confirmable.attempt_set_password(user_params)

      # this section is patterned off of devise 3.2.5 confirmations_controller#show

      self.resource = resource_class.confirm_by_token(params[:confirmation_token])
      yield resource if block_given?

      if resource.errors.empty?
        log_action( "invitee confirmed" )
        set_flash_message(:notice, :confirmed) if is_flashing_format?
          # sign in automatically
        sign_in_tenanted_and_redirect(resource)

      else
        log_action( "invitee confirmation failed" )
        respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
      end

      else
        log_action( "invitee password set failed" )
        prep_do_show()  # prep for the form
        respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :show }
    end  # if..then..else passwords are valid
  end

  def show
    if @confirmable.new_record?  ||
       !::Milia.use_invite_member || 
       @confirmable.skip_confirm_change_password

      log_action( "devise pass-thru" )
      self.resource = resource_class.confirm_by_token(params[:confirmation_token])
      yield resource if block_given?

      if resource.errors.empty?
        set_flash_message(:notice, :confirmed) if is_flashing_format?
      end

      if @confirmable.skip_confirm_change_password
        sign_in_tenanted_and_redirect(resource)
      end
    else
      log_action( "password set form" )
      flash[:notice] = "Please choose a password and confirm it"
      prep_do_show()  # prep for the form
    end
      # else fall thru to show template which is form to set a password
      # upon SUBMIT, processing will continue from update
  end

  def after_confirmation_path_for(resource_name, resource)
    if user_sign_in?
     root_path
    else
      new_user_session_path
    end
  end

  private 

  def set_confirmable()
    @confirmable = User.find_or_initialize_with_error_by(:confirmation_token, params[:confirmation_token])
  end
end

应用程序/视图/色器件/邮寄者/ confirmation_instructions.html.erb

<p><%= t('.greeting', :recipient => @resource.email, :default => "Welcome #{@resource.email}!") %></p>

<p><%= t('.instruction', :default => "You can confirm your account email through the link below:") %></p>

<p><%= link_to t('.action', :default => "Confirm my account"),
    user_confirmation_url(:confirmation_token => @token, locale: I18n.locale) %></p>

0 个答案:

没有答案