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 8334221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:16:34+00:00 2026-06-09T03:16:34+00:00

I have a session controller like def create user = User.find_by_email(params[:session][:email]) if user &&

  • 0

I have a session controller like

def create
    user = User.find_by_email(params[:session][:email])
    if user && user.authenticate(params[:session][:password])
      sign_in user
      redirect_to user
    else
      flash.now[:error] = 'Invalid email/password combination' # Not quite right!
      render 'new'
    end
  end

if you notice on successful sign in it does redirect_to user which is the show action in the User controller.

But say instead of that I have to go to the new action of user controller then how do i do that?

  • 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-09T03:16:36+00:00Added an answer on June 9, 2026 at 3:16 am

    redirect_to user is just a shortcut for redirect_to url_for(user), which generates the url for a given resource (url_for) and then redirects to it.

    If you want to redirect to another url, you can use the path helper.

    redirect_to new_user_path
    

    You could also use the url_for helper to generate an url.

    redirect_to url_for(:controller => "users", :action => "new")
    

    Which can be shortened to

    redirect_to :controller => "users", :action => :new
    

    You can even specify an url directly (redirect_to '/users/new') – which I would not recommend, as you can’t change your routing later without changing all the urls.

    The docs

    As you can see, there are many ways to specify an url to redirect_to in rails. Take a look at the documentation for all of them

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Controller Call user = User.authenticate(params[:session][:email], params[:session][:password]) Authenticate Method in user.rb class << self def
I have a controller sessions that can create session. I'd like to call it
Should I constantly have a session open in my web site with user accounts,
If i have a configuration file like this # config/environments/integration.rb config.action_controller.session = { :domain
I have this ruby function in a controller def updateSession value case value when
Having followed a tutorial online, I have a sessions controller that looks like: class
I'm using devise for my user registrations and I'd like to have a separate
I have this line in my votes controller: before_filter :authenticate So when I vote
I'm upgrading an app to Rails 3. We have an Application Controller like the
wonder if someone could help me with a little problem. I have session values

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.