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

  • Home
  • SEARCH
  • 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 4008578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:46:21+00:00 2026-05-20T08:46:21+00:00

I cannot seem to figure out why this comparison is not working: if params[:password].to_s

  • 0

I cannot seem to figure out why this comparison is not working:

if params[:password].to_s == params[:conf_password].to_s
  #do something
else
  #do something else

The result is always false, executing the else block… Anyone know why?

Edit: Checking the output shows that the two parameters are identical. “password” is collected using a ‘form_for’ and “conf_password” from a password_field_tag.

If “conf_password” is included in the ‘form_for’ a no such method error is thrown, because there is no column conf_password in the model. Perhaps there is a better way of collecting this param, which may solve the issue.

some log output regarding params.

PARAMS: {"password"=>"1234567", "company"=>"company1", "companykey"=>"ckey2"}, "conf_password"=>"1234567", 

Code to get these values

<tr> <td> <%= label_tag(:password, "Password") %> </td> <td> <%= f.password_field :password %> </td> </tr>

<tr> <td> <%= label_tag(:conf_password, "Confirm Password") %> </td> <td> <%= password_field_tag(:conf_password) %> </td> </tr>
  • 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-20T08:46:22+00:00Added an answer on May 20, 2026 at 8:46 am

    It seems to me that you should not be accessing :password and :conf_password the same way as the :password parameter is within a hash while :conf_password is not.

    When you declare the form_for you also define the hash that contains the :password and you have to access the :password-parameter with new Object(params[:object]).password. You are able to access the parameter with params[:object][:password] as well.

    Untested example form based on copy-paste coding

    <%= form_for @person do |f| %>
      <%= f.label :first_name %>:
      <%= f.text_field :first_name %><br />
    
      <%= f.label :password %>:
      <%= f.text_field :password %><br />
    
      <%= f.submit %>
    <% end %>
    

    Untested example controller based on deduction not knowledge

    if Person.create(params[:person]).password == 'foobar'
       # go on
    else 
       # fail
    end
    

    For more though out description see the API: http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

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

Sidebar

Related Questions

I cannot seem to figure out where I went wrong with this. favorite share
After several hours of tinkering I cannot seem to figure this out. I have
I cannot seem to figure out what is making this script go wrong... You
I know this is easy, but I cannot seem to figure this out. I
I'm trying to code something with generics, but cannot seem to figure out how
I cannot seem to figure out I am getting the following error in IE
Looking over the magento 1.5 schema I cannot seem to figure out how a
I can not seem to figure out how to count the number of seconds
I cannot seem to get this date picker working at all. I know it
I cannot seem to figure out how to do a Selection Alignment in 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.