I have started to get the error message "wrong number of arguments (1
for 0)" since I upgraded to Gusty Gibbon.
I am new to ROR so I have no clue.
This is the code that was running
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = ''User was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
andf this is the stack trace any help would be appreciated
ArgumentError in Access/userController#create
wrong number of arguments (1 for 0)
RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace
app/models/user.rb:17:in `initialize''
app/models/user.rb:17:in `new''
app/models/user.rb:17:in `hashed''
app/models/user.rb:35:in `update_password''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:333:in `send''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:333:in `callback''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:330:in `each''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:330:in `callback''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:241:in `create_or_update''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/base.rb:
1533:in `save_without_validation''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
validations.rb:752:in `save_without_transactions''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:129:in `save''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/abstract/database_statements.rb:59:in
`transaction''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:95:in `transaction''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:121:in `transaction''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:129:in `save''
app/controllers/access/user_controller.rb:29:in `create''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
1095:in `send''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
1095:in `perform_action_without_filters''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:632:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:638:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:438:in `call''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:637:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:638:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:438:in `call''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:637:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:619:in `perform_action_without_benchmark''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
rescue.rb:83:in `perform_action''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
430:in `send''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
430:in `process_without_filters''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:624:in `process_without_session_management_support''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session_management.rb:114:in `process''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
330:in `process''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/webrick_server.rb:79:in
`service''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/commands/servers/webrick.rb:59
/var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
dependencies.rb:496:in `require''
/var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
dependencies.rb:343:in `new_constants_in''
/var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
dependencies.rb:496:in `require''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/commands/server.rb:39
-e:4:in `load''
-e:4
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:41:in `dispatch''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/webrick_server.rb:113:in
`handle_dispatch''
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/webrick_server.rb:63:in
`dispatch''
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require''
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require''
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require''
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require''
script/server:5
app/models/user.rb:17:in `initialize''
app/models/user.rb:17:in `new''
app/models/user.rb:17:in `hashed''
app/models/user.rb:35:in `update_password''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:333:in `send''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:333:in `callback''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:330:in `each''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:330:in `callback''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
callbacks.rb:241:in `create_or_update''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/base.rb:
1533:in `save_without_validation''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
validations.rb:752:in `save_without_transactions''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:129:in `save''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/abstract/database_statements.rb:59:in
`transaction''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:95:in `transaction''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:121:in `transaction''
/var/lib/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
transactions.rb:129:in `save''
app/controllers/access/user_controller.rb:29:in `create''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
1095:in `send''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
1095:in `perform_action_without_filters''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:632:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:638:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:438:in `call''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:637:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:638:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:438:in `call''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:637:in `call_filter''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:619:in `perform_action_without_benchmark''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue''
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
benchmarking.rb:66:in `perform_action_without_rescue''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
rescue.rb:83:in `perform_action''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
430:in `send''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
430:in `process_without_filters''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
filters.rb:624:in `process_without_session_management_support''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/
session_management.rb:114:in `process''
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:
330:in `process''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/dispatcher.rb:41:in `dispatch''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/webrick_server.rb:113:in
`handle_dispatch''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/webrick_server.rb:79:in
`service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/webrick_server.rb:63:in
`dispatch''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/commands/servers/webrick.rb:59
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require''
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require''
/var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
dependencies.rb:496:in `require''
/var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
dependencies.rb:343:in `new_constants_in''
/var/lib/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
dependencies.rb:496:in `require''
/var/lib/gems/1.8/gems/rails-1.2.1/lib/commands/server.rb:39
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require''
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require''
script/server:5
-e:4:in `load''
-e:4
Request
Parameters: {"user"=>{"lastName"=>"Bragg",
"username"=>"percivalbragg",
"firstName"=>"Percival",
"phone"=>"315-457-3000",
"fax"=>"", "password"=>"kin2ja",
"active"=>"t",
"email"=>"percivalbragg-/E1597aS9LQAvxtiuMwx3w@public.gmane.org"},
"commit"=>"Create"}
Show session dump
---
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-29 17:16 UTC
Re: error message after upgrading to Gusty Gibbon Ubuntu
On 29 Oct 2007, at 16:53, Percival wrote:> > I have started to get the error message "wrong number of arguments (1 > for 0)" since I upgraded to Gusty Gibbon. > > I am new to ROR so I have no clue. > > This is the code that was running > def create > @user = User.new(params[:user]) > if @user.save > flash[:notice] = ''User was successfully created.'' > redirect_to :action => ''list'' > else > render :action => ''new'' > end > end > > andf this is the stack trace any help would be appreciated > > ArgumentError in Access/userController#create > > wrong number of arguments (1 for 0) > > RAILS_ROOT: script/../config/.. > Application Trace | Framework Trace | Full Trace >Well there''a clearly something interesting happening here> app/models/user.rb:17:in `initialize'' > app/models/user.rb:17:in `new'' > app/models/user.rb:17:in `hashed'' > app/models/user.rb:35:in `update_password''but you haven''t shown us what''s in that file so it''s hard to guess what might be wrong Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Here is the model users.rb
class User < ActiveRecord::Base
has_and_belongs_to_many :groups
attr_accessor :password
attr_protected :hashed_password
validates_uniqueness_of :username
validates_confirmation_of :password,
:if => lambda{|user| user.new_record? or not user.password.blank?}
validates_length_of :password, :within => 6..20,
:if => lambda{|user| user.new_record? or not user.password.blank?}
def self.hashed(str)
Digest::SHA1.new(str).to_s
end
# If user matching the credentials is found, return User object
# if no matching user is found, return nil
def self.authenticate(user_info)
user = find_by_username(user_info[:username])
if user && user.hashed_password == hashed(user_info[:password])
return user
end
end
private
before_save :update_password
# Updates the hashed_password if a plain password was provided
def update_password
if not password.blank?
self.hashed_password = self.class.hashed(password)
end
end
end
Hope this helps.
On Oct 29, 1:16 pm, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 29 Oct 2007, at 16:53, Percival wrote:
>
>
>
>
>
> > I have started to get the error message "wrong number of
arguments (1
> > for 0)" since I upgraded to Gusty Gibbon.
>
> > I am new to ROR so I have no clue.
>
> > This is the code that was running
> > def create
> > @user = User.new(params[:user])
> > if @user.save
> > flash[:notice] = ''User was successfully
created.''
> > redirect_to :action => ''list''
> > else
> > render :action => ''new''
> > end
> > end
>
> > andf this is the stack trace any help would be appreciated
>
> > ArgumentError in Access/userController#create
>
> > wrong number of arguments (1 for 0)
>
> > RAILS_ROOT: script/../config/..
> > Application Trace | Framework Trace | Full Trace
>
> Well there''a clearly something interesting happening here
>
> > app/models/user.rb:17:in `initialize''
> > app/models/user.rb:17:in `new''
> > app/models/user.rb:17:in `hashed''
> > app/models/user.rb:35:in `update_password''
>
> but you haven''t shown us what''s in that file so
it''s hard to guess
> what might be wrong
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---