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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:37:15+00:00 2026-06-09T22:37:15+00:00

I am working through the rails tutorial (railstutorial.org) and noticed an issue with the

  • 0

I am working through the rails tutorial (railstutorial.org) and noticed an issue with the sign in form when a validation occurs. My route for this action is:

match '/signin',  to: 'sessions#new'

When a validation occurs the URL for the page switches to /sessions. My controller for sessions looks like this:

class SessionsController < ApplicationController

  def new
  end

  def create
    user = User.find_by_email(params[:session][:email])
    if user && user.authenticate(params[:session][:password])
      sign_in user
      redirect_back_or user
    else
      flash.now[:error] = "Invalid email/password combination"
      render 'new'
    end
  end

My question is how to have this validated form still appear with the url of /signin. Thank you.

  • 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-09T22:37:16+00:00Added an answer on June 9, 2026 at 10:37 pm

    If you want to keep using restful routing (which is the current and long time standard for Rails), you can’t. If you don’t mind deviating from this path you can create some custom routes instead of using the “normal” resource-style routing.

    First you have to change your controller and move the sign in actions from the create method to the new method (which is what /signin routes to):

    class SessionsController < ApplicationController
      def new
        if request.post?
          user = User.find_by_email(params[:session][:email])
          if user && user.authenticate(params[:session][:password])
            sign_in user
            redirect_back_or user
          else
            flash.now[:error] = "Invalid email/password combination"
          end
        end
      end
    end
    

    This means both the initial GET /signin request and the eventual POST /signin requests will get handled by the same action. If a POST was detected it will try to log in the user and redirect on success. If a GET request was made it will simply render the form as normal.

    Then you have to change your login form (app/views/sessions/new.html.erb) to use the signin path instead of the normal route:

    <% form_tag '/signin' do %>
      ....
    <% end -%>
    

    That should do it.

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

Sidebar

Related Questions

I'm working my way through Hartl's Rails Tutorial (http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec:cucumber). I finished through chapter 9
I'm working through the Ruby on Rails Tutorial at http://railstutorial.org/ , chapter 4, listing
I'm working through Michael Hartl's Ruby on Rails tutorial on http://ruby.railstutorial.org . I'm having
I am just trying to walk through this tutorial http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html#redis_and_rails And when I put
I'm currently going through a RoR tutorial ( http://railstutorial.org/chapters/sign-in-sign-out#sec:signin_success is the relevant section) which
I'm trying to teach myself rails by going through http://railstutorial.org/ . I quit working
I am currently working through http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec:current_use r] 1 and I am having trouble understanding
I'm new to Rails, and I was working through the tutorial here: http://guides.rubyonrails.org/getting_started.html When
I am working through this tutorial book and have run into an issue with
I'm working through the rails tutorial and have gotten stuck. Starting at Listing 8.16

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.