Hey i have this testing action in my controller def update_paids o = Order.find(6) o.paid=false o.save! end and i can''t get it to work, changes are not pushed to database! ive also tried to do this by update_attributes method, no effect as well. I have attr_accessor :paid in Order model. When i look on server log i only see query that loads model (i confirmed it finds correct object) Order Load (62.8ms) SELECT "orders".* FROM "orders" WHERE "orders"."id" = ? LIMIT 1 [["id", 6]] there is no update or any other query after that. What''s wrong? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Feb 12, 2012 at 9:43 AM, Marcin S <msporysz06-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey i have this testing action in my controller > > def update_paids > o = Order.find(6) > o.paid=false > o.save! > end > > and i can''t get it to work, changes are not pushed to database! ive > also tried to do this by update_attributes method, no effect as well. > > I have attr_accessor :paid in Order model. > When i look on server log i only see query that loads model (i > confirmed it finds correct object) > > Order Load (62.8ms) SELECT "orders".* FROM "orders" WHERE > "orders"."id" = ? LIMIT 1 [["id", 6]] > > there is no update or any other query after that. > What''s wrong? >Is that action routed? -- Leonardo Mateo. There''s no place like ~ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 February 2012 12:43, Marcin S <msporysz06-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey i have this testing action in my controller > > def update_paids > o = Order.find(6) > o.paid=false > o.save! > end > > and i can''t get it to work, changes are not pushed to database! ive > also tried to do this by update_attributes method, no effect as well. > > I have attr_accessor :paid in Order model.You should not have attr_accessor for a db column (I presume it is in the db). That will provide accessor methods that override the access to the db column, effectively replacing it with a simple instance method. You might mean attr_accessible. I guess you are seeing nothing in the log as the record has not changed so it does not save it. Colin> When i look on server log i only see query that loads model (i > confirmed it finds correct object) > > Order Load (62.8ms) SELECT "orders".* FROM "orders" WHERE > "orders"."id" = ? LIMIT 1 [["id", 6]] > > there is no update or any other query after that. > What''s wrong? >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2012/2/12 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>:> On 12 February 2012 12:43, Marcin S <msporysz06-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hey i have this testing action in my controller >> >> def update_paids >> o = Order.find(6) >> o.paid=false >> o.save! >> end >> >> and i can''t get it to work, changes are not pushed to database! ive >> also tried to do this by update_attributes method, no effect as well. >> >> I have attr_accessor :paid in Order model. > > You should not have attr_accessor for a db column (I presume it is in > the db). That will provide accessor methods that override the access > to the db column, effectively replacing it with a simple instance > method. You might mean attr_accessible. I guess you are seeing > nothing in the log as the record has not changed so it does not save > it.Thanks You that was it! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.