Hi all, i have a form and the form is validating correctly. the relevant table to this model has a coloum to store a some text(a auto generated text.). to store text to this coloum i am not giving it from a normal form. instead of that i want to pass a values to this model from a another different model so it can save in the table. pls any one know how to archive this task. Thank Nadeesha -- 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 -~----------~----~----~----~------~----~------~--~---
So if I understand you correctly, it sounds like you have two models: A and B. Model A has an attribute that allows text to be stored in it, and this attribute is populated by model B. So, what you want to do is: class B < ActiveRecord::Base # id: the id of the record where the text should be stored # text: the text to be stored def populate_text_field(id, text) if a = A.find(id) a.update_attribute(:text_field, text) end end end Is this what you are intending? On Dec 5, 8:44 pm, Nadeesha Meththananda <rails-mailing-l...@andreas- s.net> wrote:> Hi all, > > i have a form and the form is validating correctly. the relevant table > to this model has a coloum to store a some text(a auto generated text.). > to store text to this coloum i am not giving it from a normal form. > instead of that i want to pass a values to this model from a another > different model so it can save in the table. > > pls any one know how to archive this task. > > Thank > Nadeesha > -- > 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 -~----------~----~----~----~------~----~------~--~---
Matt White wrote:> So if I understand you correctly, it sounds like you have two models: > A and B. Model A has an attribute that allows text to be stored in it, > and this attribute is populated by model B. So, what you want to do > is: > > class B < ActiveRecord::Base > > # id: the id of the record where the text should be stored > # text: the text to be stored > def populate_text_field(id, text) > if a = A.find(id) > a.update_attribute(:text_field, text) > end > end > > end > > Is this what you are intending? > > On Dec 5, 8:44 pm, Nadeesha Meththananda <rails-mailing-l...@andreas-Hi Thanks for the tip. i think ur solution can help me to archive the solution i want. Thanks Nadeesha -- 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 -~----------~----~----~----~------~----~------~--~---