Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Params Hash issues?

#2259

Running into issue with converting submitted form elements into correct params, as compared to rails 2.2 behavior...

RAILS 2.2 APP FORM


<form action="/session" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="99e3738d859713c4de837759a5cf128b5a1a8442" /></div>
  <fieldset>
    <p>
      <label for="session_email">Email</label>
      <input id="session_email" name="session[email]" size="30" type="text" />  
    </p>
    <p>
      <label for="session_password">Password</label>
      <input id="session_password" name="session[password]" size="30" type="password" />
    </p>
  </fieldset>
</form>

RAILS 2.2 When submitted...

Processing SessionsController#create (for 127.0.0.1 at 2009-03-16 16:56:15) [POST]
Parameters: {"commit"=>"Sign in", "action"=>"create", "authenticity_token"=>"99e3738d859713c4de837759a5cf128b5a1a8442", "session"=>{"password"=>"[FILTERED]", "email"=>"test@test.test"}, "controller"=>"sessions"}

RAILS 2.3 APP FORM


<form action="http://localhost:4000/admin/session" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="Z0lxRua6hNovMIYkuiNCUwS5QijrKAyi5nZXjD8uOI4=" /></div>  <fieldset>
    <p>
      <label for="user_email">Email</label><br />
      <input id="user_email" name="user[email]" size="30" type="text" />
    </p>
    <p>
      <label for="user_password">Password</label><br />
      <input id="user_password" name="user[password]" size="30" type="password" />
    </p>
  </fieldset>
</form>

RAILS 2.3 When submitted...

Processing Admin::SessionController#create (for 127.0.0.1 at 2009-03-16 16:56:36) [POST]
Parameters: {"commit"=>"Login", "authenticity_token"=>"Z0lxRua6hNovMIYkuiNCUwS5QijrKAyi5nZXjD8uOI4=", "user[email]"=>"test@test.test", "user[password]"=>"test"}

Note the difference in how basically similar form elements are turned into params...


{ "session"=>{"password"=>"[FILTERED]", "email"=>"test@test.test"} }

{ "user[email]"=>"test@test.test", "user[password]"=>"test" }

...and how the first is a nested hash (as expected), but rails 2.3 is not.

Reported by Matt Jankowski · March 16th, 2009 @ 09:27 PM

State: wontfix
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. Matt Jankowski
    Matt Jankowski

    This seems to work correctly in test mode, I added a "puts params.inspect" line to the #create action where this was occurring in development mode. Results are as expected in test...

    
    {"user"=>{"password"=>"mock", "email"=>"mock"}, "action"=>"create", "controller"=>"admin/session"}
    

    March 16th, 2009 @ 09:38 PM

  2. josh
    josh
    • State changed from new to wontfix
    • Assigned user set to josh

    This is related to a rack gem loading issue. Rack 0.9 doesn't support nested params (yet), however the soon to be release rack 1.0 does. We've bundled rack 1.0 with Rails but there were some known loading issues in RC2 but were fix in the final release.

    March 16th, 2009 @ 09:54 PM

  3. Matt Jankowski
    Matt Jankowski

    Ok, this is happening on a 2.3.2 app which was updated with "rake rails:freeze:edge RELEASE=2.3.2" (and pulled down the zip, etc) shortly after the release today.

    I also confirmed that this happens with a v2.3.2 tarball downloaded from github.

    March 16th, 2009 @ 10:06 PM

  4. Matt Jankowski
    Matt Jankowski

    New info...

    This does NOT happen using mongrel_rails to run the app under mongrel, but it does happen when using 'thin start' to run the app with thin.

    March 16th, 2009 @ 10:07 PM

  5. Matt Jankowski
    Matt Jankowski

    Attempted using both thin 1.0.0 from rubygems and thin 1.1.0 from github, which I think is the latest stable thin gem release.

    March 16th, 2009 @ 10:11 PM

  6. josh
    josh

    The v2.3.2 git tag is wrong. The next commit includes this fix. However the 2.3 gem version was built from the correct source.

    March 16th, 2009 @ 10:27 PM

  7. Matt Jankowski
    Matt Jankowski

    Ok, thanks for the help. I pulled from edge instead of the 2.3.2 tag, and it's fine now.

    Maybe clarify this mis-tagging on the official release blog post or something? I could see this driving people mad if they happen to be using thin in local development...

    March 16th, 2009 @ 11:12 PM

  8. Luigi Montanez
    Luigi Montanez

    Agreed, please fix the 2.3.2 tag. It's what's used to generate the .tar.gz archive at dev.rubyonrails.org, so anyone using that gets a bad version of Rails 2.3.2.

    March 18th, 2009 @ 03:08 PM

  9. Tomas Varsavsky
    Tomas Varsavsky

    I'm having the same issue but did not freeze rails gems from the git repo. I did:

    gem install rails --version 2.3.2 RAILS_GEM_VERSION = '2.3.2' in my environment.rb rake rails:freeze:gems

    From what I can gather in the comments above, I should not have a broken version.

    March 30th, 2009 @ 12:52 PM

  10. Tomas Varsavsky
    Tomas Varsavsky

    Updated to edge rails, problem persists. I'm using latest released Rack 0.9.1.

    March 30th, 2009 @ 01:10 PM

  11. Tomas Varsavsky
    Tomas Varsavsky

    The problem was that I had Rack 0.9.1 as a dependent gem in my environment.rb which conflicted with the version of Rack that is bundled with Rails 2.3.2. I had added rack 0.9.1 as a dependency because Rspec 1.2.2 needs it. I moved the rack dependency to test.rb and now everything works.

    March 31st, 2009 @ 09:07 AM

  12. Matthew Williams
    Matthew Williams
    • Tag set to 2.3.2.1, bug, hash, params

    I'm showing the exact same behavior but unlike Tomas, I do not have Rack 0.9.1 as a dependent gem anywhere.

    Has anyone come up with a solid resolution for this problem yet?

    April 15th, 2009 @ 04:59 PM

  13. Matthew Williams
    Matthew Williams

    Disregard previous message.

    I'm sending an empty param from a hidden field which Rack 1.0 is now blowing up on. Removing the hidden field solves my problem and the params are handled correctly but a main functionality of my application is now broken because Rack doesn't like that empty hidden field.

    April 15th, 2009 @ 05:05 PM