Welcome Guest | Login

Problem with params

Hi all,

I'm hoping one of you experts can help me out as I'm a little stuck. I'm receiving a ArgumentError in AccountController#change_password wrong number of arguments (1 for 0) when trying to get params([:user]). The params come from a change password form.

I can't pinpoint where I'm going wrong and the stack trace doesn't seem to be telling me much, or I don't understand what it is trying to tell me.

Here is the trace;

app/controllers/account_controller.rb:34:in `params'
app/controllers/account_controller.rb:34:in `change_password'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:638:in `call_filter'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:438:in `call'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:637:in `call_filter'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:638:in `call_filter'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:438:in `call'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:637:in `call_filter'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'
/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `each'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in `load'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in `load'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in `load'
/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'
/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3

The controller (line 3 as i've shorted it):
def change_password
  @user = User.find_by_id(@login_id.id)
  @whywontyouwork = params([:user])
  if request.post?
  end
end

Obviously, the method doesn't do anything as I haven't quite got that far yet. @login_id.id is an instance variable in the application.rb file which allows me to place user information like username and role on the main page etc.

This is the change_password form;

<div id="list">
<div id="header">
 <h2>Changing your password..</h2>
</div>
<p>To change your password, please provide both your old password and your new password. You must also confirm your new password so that you haven't entered it incorrectly.</p>
<p>Required fields are marked with a *</p>
<%= error_messages_for 'user' %>
<% form_for :user, :html => { :id => 'signup' } do |form| %>
<fieldset>
 <legend>Enter old and new details.. </legend>
 <p class="p">
  <label for="user_name" class="clear-left float-left text-left">Username</label>
  <label for="user_name" style="height: 33px;" class="float-left"><%= @login_id.name %><label>
 </p>
 <p class="p">
  <label for="user_password_box" class="clear-left float-left text-left">Choose a password<em>*</em></label>
  <%= form.password_field :password, :size => 40 %>
 </p>
 <p class="p">
  <label for="user_password_confirmation" class="clear-left float-left text-left">Re-enter password<em>*</em></label>
  <%= form.password_field :password_confirmation, :size => 40 %>
 </p>
</fieldset>
<fieldset>
 <legend>Confirm you are you.. </legend>
 <p class="p">
  <%= show_simple_captcha(:object=>"user", :image_style => "simply_green", :distortion => "low") %>
 </p>
 <p class="p">
  <%= submit_tag "Signup", :class => 'form' %>
 </p>
</fieldset>
<% end %>
</div>

Could somebody help me with this error as I am unable to find where it is coming from?

Thanks,
Paul

2007-10-21 03:48 PM

Hi there - try

@thisshouldwork = params[:user]

instead of

@whywontyouwork = params([:user])

2007-10-22 02:01 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!