I have several validations applied to my model:
class Quote < ActiveRecord::Base
has_many :files
validates_presence_of :title, :source, :quote, :message => "Missing
Field Required"
validates_length_of :title, :source, :maximum => 80, :message =>
"Maximum Length 80 characters"
validates_inclusion_of :year, :in=>1911..2006, :message => "Year must
be
between 1911-2006"
end
I am getting this error when I try to create a new record (actually,
when I comment out the validation, I still get same errors):
=====ArgumentError in Quotes#create
wrong number of arguments (2 for 0)
RAILS_ROOT: /var/www/learningq/public/../config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1628:in
`quote''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1628:in
`attributes_with_quotes''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1749:in
`inject''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1626:in
`attributes_with_quotes''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1718:in
`quoted_column_names''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1448:in
`create_without_callbacks''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/callbacks.rb:261:in
`create_without_timestamps''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/timestamp.rb:30:in
`create''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1431:in
`create_or_update_without_callbacks''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/callbacks.rb:249:in
`create_or_update''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1231:in
`save_without_validation''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/validations.rb:687:in
`save_without_transactions''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/transactions.rb:126:in
`save''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in
`transaction''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/transactions.rb:91:in
`transaction''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/transactions.rb:118:in
`transaction''
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/transactions.rb:126:in
`save''
#{RAILS_ROOT}/app/controllers/quotes_controller.rb:21:in `create''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:841:in
`perform_action_without_filters''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in
`perform_action''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:365:in
`process_without_session_management_support''
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in
`process''
#{RAILS_ROOT}/vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch''
#{RAILS_ROOT}/vendor/rails/railties/lib/fcgi_handler.rb:141:in
`process_request''
#{RAILS_ROOT}/vendor/rails/railties/lib/fcgi_handler.rb:53:in
`process!''
/usr/lib/ruby/1.8/fcgi.rb:600:in `each_cgi''
/usr/lib/ruby/1.8/fcgi.rb:597:in `each_cgi''
#{RAILS_ROOT}/vendor/rails/railties/lib/fcgi_handler.rb:52:in
`process!''
#{RAILS_ROOT}/vendor/rails/railties/lib/fcgi_handler.rb:22:in
`process!''
/var/www/learningq/public/dispatch.fcgi:26
Request
Parameters: {"commit"=>"Create",
"quote"=>{"created_on(2i)"=>"12",
"created_on(3i)"=>"16",
"created_on(4i)"=>"04", "title"=>"Test
Title",
"created_by"=>"test_created",
"created_on(5i)"=>"45",
"lock_version"=>"false",
"quote"=>"quote example text",
"year"=>"1980",
"created_on(1i)"=>"2005",
"source"=>"Source example"}}
Show session dump
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
======
--
Posted via http://www.ruby-forum.com/.