Search code examples
ruby-on-railsherokuruby-on-rails-3.1parameters

Rails parameters going missing


I'm having a bit of trouble with Rails parameters being filtered or not being parsed. It works fine when it's running locally on WEBRick but once it's up on Heroku it ignores a bunch of submitted form parameters (they aren't added to params[]).

I submit the form and it falls over because it's expecting a value that isn't there. Airbrake tells me that rack.request.form_hash is this:

{"utf8"=>"✓", "_method"=>"put", "authenticity_token"=>"8CZUmWc7qB1mWAbyn9NeGmygRVczdZCtI3CXwu0DUV4=", "survey_entry"=>{"pupil"=>{"id"=>"2784", "non_vrh"=>"f", "initials"=>"A", "surname"=>"ABC", "year_group_id"=>"5", "age_this_september_years"=>"", "age_this_september_months"=>"", "current_reading_level"=>""}, "questionnaire"=>{"answer"=>{"21"=>"6", "22"=>"2", "39"=>"", "40"=>""}}}}

But it also tells me that action_dispatch.request.parameters is this:

{"utf8"=>"✓", "_method"=>"put", "authenticity_token"=>"8CZUmWc7qB1mWAbyn9NeGmygRVczdZCtI3CXwu0DUV4=", "survey_entry"=>"", "action"=>"update", "controller"=>"survey_entries", "id"=>"7"}

So it's doubtless something noobish and foolish that I'm doing but it's got me flummoxed at the moment :/


UPDATE

Curiously, a form submitted from the same page (but with slightly different fields) works fine:

utf8:✓

_method:put

authenticity_token:HLCXURx1BosuXlVYwBuOP+DxJwdY3SKwilx1CJDuwT8=

survey_entry[pupil][id]:2485

survey_entry[pupil][non_vrh]:f

survey_entry[pupil][initials]:AAS

survey_entry[pupil][surname]:ABC

survey_entry[pupil][year_group_id]:4

survey_entry[pupil][attendance_pct]:

survey_entry[pupil][reading_level][at_placement]:12

survey_entry[pupil][reading_level][at_term1]:

survey_entry[pupil][reading_level][at_term2]:

survey_entry[pupil][reading_level][at_term3]:

survey_entry[pupil][previous_progress]:

survey_entry[pupil][target_rl_id]:

survey_entry[pupil][english_first_language]:0

survey_entry[pupil][english_first_language]:1

survey_entry[pupil][care_order]:0

survey_entry[pupil][lac_funded]:0

survey_entry[pupil][free_meals]:0

survey_entry[pupil][selection_reason_id]:4

survey_entry[pupil][other_selection_reason]:

survey_entry[questionnaire][answer[3]]:2

survey_entry[questionnaire][answer[4]]:2

survey_entry[questionnaire][answer[13]]:3

survey_entry[questionnaire][answer[14]]:3

survey_entry[questionnaire][answer[20]]:3


Solution

  • OK, suffice to say that I was being really stupid. I'll blame it on being a bit under the weather. Thanks to Steve for trying to help, I shall now crawl off in shame :)