I want to do a "raw" update an attribute on a ActiveRecord model without Rails doing type checks on the underlying column in my db. In other words - I want the create/update equivalent of "attributes_before_type_cast" which I can use when i read the column. In my particular example I would like to set a DATE column in Mysql to "1970-00-00" for example. Mysql lets me set this value in a DATE column. When I try to set this value in Rails, the column gets nulled out. Appreciate any help on this --Mats --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Use SQL, inside your model. sql = ActiveRecord::Base.connection() sql.execute("sql statement for whatever you want to do;") You can wrap this around a particular private function that you write. Vish On 8/13/07, jumboboy <mats.jagmalm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I want to do a "raw" update an attribute on a ActiveRecord model > without Rails doing type checks on the underlying column in my db. > > In other words - I want the create/update equivalent of > "attributes_before_type_cast" which I can use when i read the column. > > In my particular example I would like to set a DATE column in Mysql to > "1970-00-00" for example. Mysql lets me set this value in a DATE > column. When I try to set this value in Rails, the column gets nulled > out. > > Appreciate any help on this > --Mats > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Mats, Not sure I understand your request, but you might be looking for save.with_validations(false) hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Vish - that worked fine! Thanks a lot! --Mats On Aug 12, 11:52 pm, "Vishnu Gopal" <g.vis...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Use SQL, inside your model. > > sql = ActiveRecord::Base.connection() > sql.execute("sql statement for whatever you want to do;") > > You can wrap this around a particular private function that you write. > > Vish > > On 8/13/07,jumboboy<mats.jagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I want to do a "raw" update an attribute on a ActiveRecord model > > without Rails doing type checks on the underlying column in my db. > > > In other words - I want the create/update equivalent of > > "attributes_before_type_cast" which I can use when i read the column. > > > In my particular example I would like to set a DATE column in Mysql to > > "1970-00-00" for example. Mysql lets me set this value in a DATE > > column. When I try to set this value in Rails, the column gets nulled > > out. > > > Appreciate any help on this > > --Mats--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---