Hello all,
I’m a bit of a Nooby on Rails (is that a new joke?) as well as a Ruby
Nooby and I’ve been trying all day to get to the bottom of an error. I
promise I have tried everything but I’ve started going round in circles
and deleting large chunks of code so it’s probably time to call in the
experts.
I’ve seen a few similar posts to this, mostly on this forum, but none
seem to be entirely applicable to my case.
I have a formtastic form which gathers some inputs and creates a new
Transaction which then generates a nasty error. it seems to be centred
on the @transaction.save action, this is where my ‘puts’ debugging
outputs stop.
I’ve done nothing (intentionally) advanced, mainly relying on defaults
and nifty_generators, so I can’t see how I’ve got myself into such a
pickle.
Any help you can offer would be very much appreciated, please let me
know if I’ve missed something you need to see. I really am going
insane.
Kind regards
Sam
[transactions_controller.rb in part]
def new
@transaction = Transaction.new
end
def create
@transaction = Transaction.new(params[:transaction])
if @transaction.save <<< this is line 36
flash[:notice] = “Successfully created transaction.”
redirect_to items_path
else
render :action => ‘new’
end
end
[The error message]
ArgumentError in TransactionsController#create
wrong number of arguments (1 for 0)
Application Trace | Framework Trace | Full Trace
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/quoting.rb:61:in
to_s' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/quoting.rb:61:in
quoted_date’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/quoting.rb:29:in
quote' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:236:in
quote’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:3033:in
attributes_with_quotes' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:3024:in
each’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:3024:in
attributes_with_quotes' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2939:in
create_without_timestamps’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/timestamp.rb:53:in
create_without_callbacks' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:266:in
create’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2915:in
create_or_update_without_callbacks' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:250:in
create_or_update’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2573:in
save_without_validation' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090:in
save_without_dirty’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79:in
save_without_transactions' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229:in
send’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229:in
with_transaction_returning_status' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in
transaction’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182:in
transaction' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228:in
with_transaction_returning_status’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in
save' /Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:208:in
rollback_active_record_state!’
/Users/sam/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196:in
save' /Users/sam/Sites/boxapp/app/controllers/transactions_controller.rb:36:in
create’
[transaction.rb model]
class Transaction < ActiveRecord::Base
#attr_accessible :item_id, :user_id, :from, :to, :status
belongs_to :item
belongs_to :user
def owner
@item = Item.find(item_id)
User.find(@item.user_id)
end
def borrower
User.find(user_id)
end
end