Forum: Ruby on Rails push_with_attributes not inserting default values

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Yash (Guest)
on 2006-03-15 05:48
I have a join table A_B with columns[a_id, b_id, c_data default 1,
d_data default 1].
If I do:
@aobj.bobjs.push_with_attributes(@bobj,{:c_data => 0})
I find that the row inserted, has d_data set to 0 and not the default
value specified in the database, which is 1. So I am having to
explicitly set it using :
@aobj.bobjs.push_with_attributes(@bobj,{:c_data => 0, :d_data => 1}).

Is this a bug in Rails 1.0?

Also, is there a way I can see the SQL generated for any ActiveRecord
method while the application is running?

Thanks,
Yash
Justin F. (Guest)
on 2006-03-19 04:54
(Received via mailing list)
Yash wrote:
>
> Also, is there a way I can see the SQL generated for any ActiveRecord
> method while the application is running?

Sorry not to have an answer for the first part of your question, but
when you are running in development mode (the default) you can see the
SQL your application is using in log/development.log

On Unix/Linux/Mac OS X, (or with Cygwin on Windows

    tail -f log/development.log

to watch what is happening as your application executes.

regards

   Justin
This topic is locked and can not be replied to.