# Params\[:obj\] not being set from a form

**URL:** <https://www.ruby-forum.com/t/params-obj-not-being-set-from-a-form/84627>\
**Category:** Rails\
**Created:** [February 6, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/params-obj-not-being-set-from-a-form/84627 "2007-02-06T16:17:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [February 6, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/params-obj-not-being-set-from-a-form/84627/1 "2007-02-06T16:17:51Z")

</div>

I have a form that looks like this:

\<%= start\_form\_tag :action =\> ‘login’ %\>

| Username: | \<%= text\_field 'user', 'username' %\> |
| Password: | \<%= password\_field 'user', 'password' %\> |

\<%= submit\_tag ‘Login’ %\>  
\<%= end\_form\_tag %\>

And in the controller, this:

def login  
if request.get?  
# If the deleted flag is set in the session, remove it  
# now and give the user a new session.  
# (when a user logs out, their session is removed too)  
reset\_session if session[:deleted]  
@user = User.new  
else  
logger.info(“params user is:”)  
logger.info(params[:user])  
@user = User.new(params[:user])  
@authenticated\_user = @user.try\_to\_authenticate

This code was written a long time ago and now I am trying to run it on  
the production server. On my development server, everything is fine.  
However on the production server (with environment set to ‘development’  
for this debugging) it seems that params[:user] is never set.

On the development server I can see usernamepassword  
in the log. On the production server, nothing is output. This  
obviously causes problems because a user object with no  
username/password is not going to authenticate (“can’t convert nil into  
String” when trying to hash the users password using Digest::SHA1).

At first I thought it might be the versions of ruby/rails etc, but both  
now report this:

About your application’s environment  
Ruby version 1.8.5 (i686-linux)  
RubyGems version 0.9.0  
Rails version 1.2.1  
Active Record version 1.15.1  
Action Pack version 1.13.1  
Action Web Service version 1.2.1  
Action Mailer version 1.3.1  
Active Support version 1.4.0

What would cause one machine to have a nil params[:user]? The two  
machines have exactly the same code.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [February 6, 2007, 4:38pm UTC](https://www.ruby-forum.com/t/params-obj-not-being-set-from-a-form/84627/2 "2007-02-06T16:38:32Z")

</div>

I had a similar problem. I resolved it by adding this line to the  
very top of my User model, before the class declaration:

require “digest/sha1”

If that doesn’t help, I’m wondering what your params object looks  
like. What does this statement produce:

logger.info(params.inspect)

– Jeff

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [February 6, 2007, 4:53pm UTC](https://www.ruby-forum.com/t/params-obj-not-being-set-from-a-form/84627/3 "2007-02-06T16:53:19Z")

</div>

Jeff wrote:

> I had a similar problem. I resolved it by adding this line to the  
> very top of my User model, before the class declaration:
> 
> require “digest/sha1”

Thanks for the suggestion, I have that inside the actual class. Using  
irb I can verify that the require returns ‘true’ and Digest::SHA1(“foo”)  
returns a correct hash.

> If that doesn’t help, I’m wondering what your params object looks  
> like. What does this statement produce:
> 
> logger.info(params.inspect)

Quite simply… it doesn’t produce anything! There is no output from  
params.inspect on the broken host. Something must be wrong, but I  
cannot figure out what.

The only major differences are:

- the production (broken) machine uses HTTPS
- the production (broken) machine uses SSL certificates for the client

I haven’t changed anything in rails to reflect the above two things, but  
POST requests do go to the right place if watching the logs.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [February 6, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/params-obj-not-being-set-from-a-form/84627/4 "2007-02-06T17:46:31Z")

</div>

David wrote:

> Jeff wrote:
> 
> > logger.info(params.inspect)
> 
> Quite simply… it doesn’t produce anything! There is no output from  
> params.inspect on the broken host. Something must be wrong, but I  
> cannot figure out what.
> 
> The only major differences are:
> 
> - the production (broken) machine uses HTTPS

This one seems to be what causes the problems. I’m using Apache and  
after disabling SSL the application works as expected.

So I suppose my question now is why isn’t params[…] filled properly if  
using an HTTPS connection?
