Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8445149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:35:13+00:00 2026-06-10T09:35:13+00:00

I’m working with rails 3.2 and Devise (the lastest version) The main idea if

  • 0

I’m working with rails 3.2 and Devise (the lastest version)

The main idea if the test some variables of the current logged user after sign in. So, for example, if the user has pending creating an address i want to redirect the new address path. But what i get is a double render error.

Here is the code

class ApplicationController < ActionController::Base
  protect_from_forgery

 # Devise: Where to redirect users once they have logged in
  def after_sign_in_path_for(resource)

        if current_user.is? :company_owner
            if $redis.hget(USER_COMPANY_KEY, current_user.id).nil?
                redirect_to new_owner_company_path and return
            else
                @addr_pending = $redis.hget(PENDING_ADDRESS_KEY,current_user.id)
                unless @addr_pending.nil? || !@addr_pending
                     redirect_to owner_company_addresses_path  and return
                end
            end
        end
        root_path
  end
end

my routes definition

  root :to => "home#index"
    devise_for :users, :controllers => { 
    :omniauth_callbacks => "users/omniauth_callbacks" 
  }
    resources :users, :only => :show

    namespace :owner do
        resource :company  do # single resource /owner/company
            get 'thanks'
            get 'owner' #TODO: esto hay que sacarlo de aquí y forme parte del login
            resources :addresses
        end
    end

So, when i login with a user with a pedding address creation i get

"render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".

what is wrong with?

 redirect_to owner_company_addresses_path  and return

So, i just want to redirect to the new address path. I don’t understand why i get the error.

Thanks in advance.

—- edit —-

Seems that only one path must be returned (I thought with redirect_to and return was enough, but it does not)

def after_sign_in_path_for(resource)

        @final_url = root_path
        if current_user.is? :company_owner
            if $redis.hget(USER_COMPANY_KEY, current_user.id).nil?
                @final_url = new_owner_company_path
            else
                @addr_pending = $redis.hget(PENDING_ADDRESS_KEY,current_user.id)
                unless @addr_pending.nil? || !@addr_pending
                     @final_url = owner_company_addresses_path
                end
            end
        end
        @final_url
  end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:35:15+00:00Added an answer on June 10, 2026 at 9:35 am

    You should remove redirect_to method call and return statement. after_sign_in_path_for should return only a path:

    E.g:

    def after_sign_in_path_for(resource)
      new_owner_company_path
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.