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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:14:33+00:00 2026-05-25T15:14:33+00:00

I am working on a ruby on rails signup/signin system. I have a ruby

  • 0

I am working on a ruby on rails signup/signin system.

I have a ruby on rails form which has a virtual attribute – password. The action in response to form submission updates the model object and saves it. Before saving the before_save: callback calls the encrypt_password method. However, I don’t think that the virtual attribute is getting the value from the form. This is because when I try signing in it fails repeatedly.The code is:

 attr_accessor :password
 attr_accessible :Name, :password, :UserName, :RegistrationName, :BusinessName              

 before_save :encrypt_password

 def encrypt_password
   self.salt = make_salt 
   self.encrypted_password=encrypt(password)
 end

 def make_salt
   secure_hash("#{Time.now.utc}--#{password}")
 end

 def encrypt(string)
   secure_hash("#{salt}--#{string}")
 end

 def secure_hash(string)
   Digest::SHA2.hexdigest(string)
 end

Ok,I checked and yes the password obtained from the form is null. But I don’t understand why. This is the code for the form:

 <h1>This is the page of <%= @merchant.Name %> </h1>

<p>Please enter the password to be used </p>
<%= random_generator %>
<%= form_for @merchant,:url=>{:action=>'approve'} do |m| %>
<%= m.label :Name %><br/>
<%= m.text_field :Name %><br/>

<%= m.label :password %><br/>
<%= m.text_field :password %><br/>
<%= m.submit "Approve" %>

<% end %>

Whatever text is being entered in the password field, is visible in the Approve action in the controller, if I print it directly with params[:merchant][:password]. But in the model it is null

  • 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-25T15:14:33+00:00Added an answer on May 25, 2026 at 3:14 pm

    like any attr_accessor, you can get it’s value with:

    instance.password
    

    Put some debugger line where you find it relevant and have a look.

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

Sidebar

Related Questions

I am working on a Ruby on Rails app which which has the following
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
I'm working with Ruby on rails 2.3.4 and I'd like to have a link
i am working in Ruby on rails.. i am new to this.. i have
I'm working on learning ruby/rails at the moment - The book i'm reading has
I have been working with Ruby on Rails for over a year now and
I'm working on a ruby on rails app which connects to Jira through jira
I am working through the Ruby-on-Rails3 Tutorial Chapter 8. I have created a form
I am working through M. Hartl's Ruby on Rails Tutorial screen casts, which involve
I am working on a Ruby on Rails 3 web application. I have a

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.