Hi,
When I added this association…
class User < ActiveRecord::Base
has_one :notify
end
…and tried then to update column in User table it will call queries
for notify table automatic?
Output
User Columns (0.041488) SHOW FIELDS FROM users
User Load (0.001544) SELECT * FROM users
WHERE (users
.nickname
= ‘jamal’) LIMIT 1
SQL (0.000373) BEGIN
SQL (0.001843) SHOW TABLES
User::Notify Load (0.001113) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.001009) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000996) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000862) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000849) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000799) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User Update (0.000362) UPDATE users
SET created_at
= ‘2007-11-17
19:02:16’, times_logged_in
= 0, hashed_password
=
‘e0195770807aa8c82b0b128d9c0423b5ad035172’, logged_at
= ‘2007-11-25
14:58:56’, nickname
= ‘Jamal’, email
= ‘[email protected]’ WHERE id
=
1
User::Notify Load (0.000768) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000781) SELECT * FROM user_notifies
WHERE
(user_notifies.user_id = 1) LIMIT 1
This is how I updated the column.
user = User.find_by_nickname ‘jamal’
=> #<User id: 1, email: “[email protected]”, nickname: “Jamal”,
hashed_password: “e0195770807aa8c82b0b128d9c0423b5ad035172”, logged_at:
“2007-11-25 14:55:52”, created_at: “2007-11-17 19:02:16”,
times_logged_in: 0>user.logged_at = Time.now
=> Sun Nov 25 14:58:56 +0100 2007user.save
=> true
Is notify resevered word? or is there something I missed