Monday 15 February 2010

ruby on rails - Has_many/belongs_to association not saving due to polymorphic associations? -


I am trying to create a log of attributes that have changed in every update of a certain message. Features are issuer and type continue , and both of these have two topical associations with the updated action , which is changed_from_id Changed_to_id and changed_to_type completely

  class issuer status  with  changed_prom_type  ActiveRecord :: Base is - Medium: update_actions ,: as in => : Changed_to has_many: update_actions ,: as = & gt; : Type the end class from the changed class and type & lt; ActiveRecord :: Base is - Medium: update_actions ,: as in => : Changed_to has_many: update_actions ,: as = & gt; : Changing End Class Updates & lt; ActiveRecord :: Base is has_many: update_action and class update action & lt; ActiveRecord :: Base is_to: change_to ,: polymorphic = & gt; The truth is included: changed, from: polymorphic = & gt; It is true that trying to save  updateAction  to  update.update_actions  is not working. Guardrail  true  both  save  and  save! , but my development.log is not being used to query any SQL queries. I do not know what I am doing, because nothing is logged (or I do not know how to find it). Working from console: 

  & gt; & Gt; Verb = updateAction.new = & gt; # & Lt; Update Action ID: Zero, changed_frame_guide: zero, changed_prom_type: zero, changed_to_id: void, changed_type_guide: zero, update_id: zero, created_at: zero, updated: zero & gt; & Gt; & Gt; Action.changed_from = to = & gt; # More lieutenant; Issuchatus ID: 2, Name: "Open", created_at: "2009-12-02 05:34:41", updated_at: "2009-12-02 05:34:41" & gt; & Gt; & Gt; Action.changed_to = to = & gt; # More lieutenant; Issustatus ID: 1, Name: "closed", created_at: "2009-12-02 05:34:30", updated_A "2009-12-02 05:34:30" & gt; & Gt; & Gt; Action.save = & gt; True & gt; & Gt; Update = update. Last = & gt; # & Lt; Update ID: 1, Description: "Yawn", created_t: "2009-12-02 05:19:25", updated_it: "2009-12-02 05:19:25" & gt; & Gt; & Gt; U.update_actions & lt; & Lt; Action = & gt; [# & Lt; UpdateAction id: 2, changed_from_id: 2, changed_from_type: "IssueStatus", changed_to_id: 1, changed_type: "issustatus", update_id: 1, created_at: "2009-12-02 05:35:16", updated_at: "2009- 12-02 05:35:16 "& gt;]] & gt; & Gt; U.save = & gt; True & gt; & Gt; U.update_actions = & gt; [# & Lt; UpdateAction id: 2, changed_from_id: 2, changed_from_type: "IssueStatus", changed_to_id: 1, changed_type: "issustatus", update_id: 1, created_at: "2009-12-02 05:35:16", updated_at: "2009- 12-02 05:35:16 "& gt;]] & gt; & Gt; U.reload = & gt; # & Lt; Update ID: 1, Description: "Yawn", created_t: "2009-12-02 05:19:25", updated_it: "2009-12-02 05:19:25" & gt; & Gt; & Gt; U.update_actions = & gt; []  

Any help would be greatly appreciated, I think I am doing something wrong, but I am too late to know what happened. thank you in advanced!

"post-text" itemprop = "text">

your first line

  action = UpdateAction.new  

For example

  action = Update.last.update_actions.build  

Here's what's happening in you (assuming you reference a real U Giving, is not updated as Swanand) - The U.Sweo line is not doing anything because it only saves unsaved related objects that you have already saved an incomplete action, Therefore related Bjekt no work saves has_many that do not seem to do it, because you need to change the region is related objects. Therefore, the update_id field of action is not being saved. You can also call action.save and fix it.

I will have update_presence_of update_id to prevent and prevent FB blocking in DB on update_actions for update_id.


No comments:

Post a Comment