Jose Ambros-ingerson wrote:
Frederick Cheung wrote:
Actually that bit in the logs show the name getting set to spanish as
well. It's also possible that you've turned off this behaviour -
ActiveRecord::Base.partial_updates (or something along those lines)
controls whether this is enabled if my memory is correct
Fred
THanks Fred and Perry for your replies.
I followed up on your suggestions yet I have not been able to make it
work as advertised.
As shown in the example below I've made sure that
ActiveRecord::Base.partial_updates
is true (as indicated by Fred and in the Railscasts episode) and tried
it in my dev machine and in the production server with the same result
(both running 2.3.5).
Any ideas on how to make it work?
does it work for you?
Thanks in advance, Jose
-------------------
$ ./script/console
Loading production environment (Rails 2.3.5)
?> ActiveRecord::Base.partial_updates
=> true
Language.first
Language Load (0.2ms) SELECT * FROM `languages` LIMIT 1
=> #<Language id: 1, name: "spanish", locale: "es">
Language.first.update_attributes({:locale=>"es"})
Language Load (0.2ms) SELECT * FROM `languages` LIMIT 1
SQL (0.1ms) BEGIN
Language Update (0.4ms) UPDATE `languages` SET `name` = 'spanish',
`locale` = 'es' WHERE `id` = 1
SQL (0.2ms) COMMIT
=> true
I've not looked / tested on 2.3.5 but it was working in 2.3.4 for me.
I was hoping you would do something like:
a = Language.first
puts a.locale
a.update_attributes({:local => 'es'})
I'm not sure with all the "lazy" execution stuff what Language.first is
doing. The select you are seeing may be after the check to see if the
record is dirty or not.
Also, I can't remember the names of the methods but there is a way to
ask if a.locale has been modified. I would also experiment with a.save
and see if it saves it or not. Last, you might have something like a
plugin that has hooked in to update_attributes.
Also, perhaps your "es" is not equal to the "es" in the database? You
might experiment with:
a = Language.first
b = a.locale
a.locale = b
a.save
That should not save anything. Also, you can ask if a.locale has
changed after setting it to b. Last, you can set a.locale to "es" and
then ask if it has changed. Maybe before a.locale is utf8 and after it
is ascii?
Not sure if this helps or not.