Okay, let me explain my problem. I''ve got a form that looks like this: - form_remote_for item, :url => list_item_path(item.list, item) do |f| %p = f.check_box :completed, :onclick => ''this.form.onsubmit()'', :index => item.id = f.text_field :content, :readonly => ''readonly'', :index => item.id, :onblur => ''this.form.onsubmit()'' = link_to_remote "(edit)", :url => edit_list_item_path(item.list, item), :method => :get It''s written in HAML. As you can see there are a couple of special things about this form: 1. I''m using the :index option for the fields because there are multiple Item forms on the same page. 2. The ''content'' text field is readonly, but when the user clicks the "(edit)" link that attribute will be removed to enable the user to edit the field. 3. The form gets submitted when the user clicks the check box or presses enter or sets the ''content'' field _out_ of focus. The action that the form gets submitted to looks like this: def update @list = current_user.lists.find(params[:list_id]) @item = @list.items.find(params[:id]) @item.update_attributes(params[:item][@item.id]) end And here is the log message: Processing ItemsController#update (for 127.0.0.1 at 2008-08-01 10:59:05) [PUT] Session ID: BAh7CDoMY3NyZl9pZCIlNmFiNjYzYmNjNDMwMGY5NzZmZGVkZjcwZTIxZDVk YWU6DHVzZXJfaWRpBiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxh c2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA==--8c3643dc2753649acded627430ae5f60037b36f8 Parameters: {"authenticity_token"=>"d1ada56a0fe0d5d80601c65215ef262e940e56bb", "_method"=>"put", "action"=>"update", "id"=>"37", "list_id"=>"6", "controller"=>"items", "item"=>{"37"=>{"completed"=>"0", "content"=>"abc"}}} [4;36;1mUser Columns (0.015000) [0m [0;1mSHOW FIELDS FROM `users` [0m [4;35;1mUser Load (0.000000) [0m [0mSELECT * FROM `users` WHERE (`users`.`id` = 1) LIMIT 1 [0m [4;36;1mList Columns (0.000000) [0m [0;1mSHOW FIELDS FROM `lists` [0m [4;35;1mList Load (0.000000) [0m [0mSELECT * FROM `lists` WHERE (`lists`.`id` = 6 AND (`lists`.user_id = 1)) [0m [4;36;1mItem Columns (0.016000) [0m [0;1mSHOW FIELDS FROM `items` [0m [4;35;1mItem Load (0.016000) [0m [0mSELECT * FROM `items` WHERE (`items`.`id` = 37 AND (`items`.list_id = 6)) [0m [4;36;1mSQL (0.000000) [0m [0;1mBEGIN [0m [4;35;1mSQL (0.000000) [0m [0mCOMMIT [0m Rendering items/update [4;36;1mItem Load (0.000000) [0m [0;1mSELECT * FROM `items` WHERE (`items`.list_id = 6) AND (`items`.`completed` = 0) ORDER BY position [0m [4;35;1mList Load (0.000000) [0m [0mSELECT * FROM `lists` WHERE (`lists`.`id` = 6) [0m Rendered items/_item (0.03100) [4;36;1mCACHE (0.000000) [0m [0;1mSELECT * FROM `lists` WHERE (`lists`.`id` = 6) [0m Rendered items/_item (0.00000) [4;35;1mCACHE (0.000000) [0m [0mSELECT * FROM `lists` WHERE (`lists`.`id` = 6) [0m Rendered items/_item (0.01500) [4;36;1mCACHE (0.000000) [0m [0;1mSELECT * FROM `lists` WHERE (`lists`.`id` = 6) [0m Rendered items/_item (0.01600) [4;35;1mCACHE (0.000000) [0m [0mSELECT * FROM `lists` WHERE (`lists`.`id` = 6) [0m Rendered items/_item (0.00000) Completed in 0.29700 (3 reqs/sec) | Rendering: 0.11000 (37%) | DB: 0.04700 (15%) | 200 OK [http://localhost/lists/6/items/37] As you can see the Item is not getting updated at all. But it renders the update.rjs template anyway and rerenders all the _item partials which contains the forms I just showed you. Anyone who can see the problem. Please take a close look at the log message like I did. It must have made me blind to stare at this. If you need any further information, please just ask. Thanks in advance, David Trasbo. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> As you can see the Item is not getting updated at all. But it renders > the update.rjs template anyway and rerenders all the _item partials > which contains the forms I just showed you. >Failing validations ? Fred> Anyone who can see the problem. Please take a close look at the log > message like I did. It must have made me blind to stare at this. If you > need any further information, please just ask. > > Thanks in advance, > David Trasbo. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:>> As you can see the Item is not getting updated at all. But it renders >> the update.rjs template anyway and rerenders all the _item partials >> which contains the forms I just showed you. >> > Failing validations ?No, actually there are no validations to fail. ): -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1 Aug 2008, at 10:57, David Trasbo wrote:> > Frederick Cheung wrote: >>> As you can see the Item is not getting updated at all. But it >>> renders >>> the update.rjs template anyway and rerenders all the _item partials >>> which contains the forms I just showed you. >>> >> Failing validations ? > > No, actually there are no validations to fail. ): >I''d change update_attributes to update_attributes! (which will raise errors if necessary). Also check that activerecord''s (new in 2.1) dirty change tracking isn''t tripping you up (save will be a no-op if there aren''t any changes to make) Fred> -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1 Aug 2008, at 10:57, David Trasbo wrote:> > Frederick Cheung wrote: >>> As you can see the Item is not getting updated at all. But it >>> renders >>> the update.rjs template anyway and rerenders all the _item partials >>> which contains the forms I just showed you. >>> >> Failing validations ? > > No, actually there are no validations to fail. ):Another thought, if you have a association called transaction, then scrap it (that breaks stuff because it will replace a method on ActiveRecord) Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:>>>> As you can see the Item is not getting updated at all. But it >>>> renders >>>> the update.rjs template anyway and rerenders all the _item partials >>>> which contains the forms I just showed you. >>>> >>> Failing validations ? >> >> No, actually there are no validations to fail. ): > > Another thought, if you have a association called transaction, then > scrap it (that breaks stuff because it will replace a method on > ActiveRecord)I don''t. I think I already tried the bang method, but I''ll try again and tell you about the result. If anyone''s got an idea, please tell. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Trasbo wrote:>> Another thought, if you have a association called transaction, then >> scrap it (that breaks stuff because it will replace a method on >> ActiveRecord) > > I don''t. I think I already tried the bang method, but I''ll try again and > tell you about the result. If anyone''s got an idea, please tell.No, the bang method doesn''t work either... By the way here is the model: class Item < ActiveRecord::Base belongs_to :list named_scope :complete, :conditions => { :completed => 1 }, :order => :position named_scope :incomplete, :conditions => { :completed => 0 }, :order => :position end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1 Aug 2008, at 11:37, David Trasbo wrote:> > David Trasbo wrote: > >>> Another thought, if you have a association called transaction, then >>> scrap it (that breaks stuff because it will replace a method on >>> ActiveRecord) >> >> I don''t. I think I already tried the bang method, but I''ll try >> again and >> tell you about the result. If anyone''s got an idea, please tell. > > No, the bang method doesn''t work either... By the way here is the > model: >In that case I''d try stepping through update_attributes with the debugger and see where it goes wrong. Fred> class Item < ActiveRecord::Base > belongs_to :list > named_scope :complete, :conditions => { :completed => 1 }, :order => > :position > named_scope :incomplete, :conditions => { :completed => 0 }, :order > => > :position > end > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---