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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:09:26+00:00 2026-05-29T06:09:26+00:00

Disclaimer: super new to rails. I’m using Rails 3.2 Anyways, I’m trying to create

  • 0

Disclaimer: super new to rails. I’m using Rails 3.2

Anyways, I’m trying to create a form for Merchants to sign in. I have a MerchantSessionsController that tries to create a new session based on signin form input:

This is what I have in my
app/views/merchant_sessions/new.html.erb

<%= form_for(:merchant_session, :url => merchant_sessions_path) do |f| %>
  <div class="field">
    <%= f.label :userName %><br />
    <%= f.text_field :userName %>
  </div>
  <div class="field">
    <%= f.label :password %><br />
    <%= f.password_field :password %>
  </div>
  <div class="actions">
    <%= f.submit "Sign in" %>
  </div>
<% end %>

The file app\controllers\merchant_sessions_controller.rb contains:

def create
    merchant = Merchant.find_by_userName(params[:userName])

    if merchant && merchant.authenticate(params[:password])
        merchant_session[:merchant_id] = merchant.id
        redirect_to root_url, :notice => "Merchanthas been logged in"
    else
        flash.now[:error] = "Invalid username or password."
        @title  = "Merchant Signin"
        render "new"
    end
end

Unfortunately, the params[:userName] and params[:password] keep getting passed as nil, even though on the debug output on the merchants signin page, I see that the userName and password are definitely being passed in.

--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
utf8: ✓
authenticity_token: 8WsOviJyY1kktPq9dDO+OFePdSKf2uGLY3Pnc4bU2tc=
merchant_session: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
  userName: asd
  password: ddsad
commit: Sign in
action: create
controller: merchant_sessions

I’ve also attempted to access the params[:action] parameter, which worked fine. Why is it that the userName and password parameters are nil? I had changed the name of the MerchantSessionsController (formerly just SessionsController), but I don’t think that should be the problem

  • 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-05-29T06:09:27+00:00Added an answer on May 29, 2026 at 6:09 am

    You’re looking in the wrong place for the username and password, note the specific structure of your YAML dump:

    merchant_session: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
      userName: asd
      password: ddsad
    

    and your form:

    <%= form_for(:merchant_session, :url => merchant_sessions_path) do |f| %>
    

    You want to look at params[:merchant_session][:userName] and params[:merchant_session][:password] instead of params[:userName] and params[:password]:

    def create
        mparams  = params[:merchant_session]
        merchant = Merchant.find_by_userName(mparams[:userName])
    
        if merchant && merchant.authenticate(mparams[:password])
            #...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: I'm a rails n00b. I'm playing around with a simple helper function that
I have this alert view (disclaimer) that pop up when app finish launching. It
Disclaimer: I'm new to unit testing and just getting my feet wet. That being
Disclaimer: the following is a sin against XML. That's why I'm trying to change
Disclaimer....I'm new to Java and OOP. I have a superclass with four subclasses. For
Disclaimer: I'm really new to ObjectiveC so I may have made fundamental errors in
Disclaimer: I'm fairly new with Gradle. I'm trying to build my project with Gradle
Disclaimer : I'm new to web development. Scenario : I've built an application using
Disclaimer, Please pardon grammatical syntax. I'm using the simple linkedin php library that is
Disclaimer: I'm relatively new to iOS programming, and am trying to teach myself the

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.