Joe Half Face
Joe Half Face

Reputation: 2333

Something wrong with redirect

User should be redirected to root_url, if reset link is expired, but instead Rails do something like render :nothing => true, just empty page.

  def edit_user_by_reset
    @user = User.find_by_password_reset_token(params[:reset_token])
    respond_to do |format|
    if @user && @user.password_link_sent_at<2.hours.ago
        format.html
   else
       redirect_to root_url
   end
  end
  end

Upvotes: 0

Views: 34

Answers (1)

Joe Half Face
Joe Half Face

Reputation: 2333

Correct way:

      def edit_user_by_reset
        @user = User.find_by_password_reset_token(params[:reset_token])
        respond_to do |format|
        if @user && @user.password_link_sent_at<2.hours.ago
            format.html
       else
            format.html {redirect_to root_url}
       end
       end
      end

If you're using respond_to, you need to provide format, otherwise nothing works.

Upvotes: 1

Related Questions