Can someone tell me where this is at or how it gets created? There must be some magic to it. Thank you, Perry -- 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 -~----------~----~----~----~------~----~------~--~---
>> a = Author.new(:name => "Test")=> #<Author:0x34eaa54 @attributes={"name"=>"Test", "email"=>nil, "created_at"=>nil}, @new_record=true> >> a.save => false >> a.errors => #<ActiveRecord::Errors:0x34e92f8 @base=#<Author:0x34eaa54 @errors=#<ActiveRecord::Errors:0x34e92f8 ...>, @attributes= {"name"=>"Test", "modified_at"=>nil, "url"=>nil, "is_active"=>false, "hashed_pass"=>nil, "email"=>nil, "created_at"=>nil}, @new_record=true>, @errors={"email"=>["can''t be blank"]}> >> a.save(false) => true Zach Inglis → Blog -- http://www.zachinglis.com → Company -- http://www.lt3media.com → Portfolio -- http://portfolio.zachinglis.com → Web Designer → Print Designer → Identity Desginer → Ruby on Rails developer → et plus. → AIM: zachinglis → MSN: zachinglis-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org → Others available on request On Jul 8, 2007, at 1:31 PM, Perry Smith wrote:> > Can someone tell me where this is at or how it gets created? There > must > be some magic to it. > > Thank you, > Perry > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Perry Smith wrote:> Can someone tell me where this is at or how it gets created? There must > be some magic to it. >In active_support/core_ext/module/aliasing.rb, there is a instance method added to module called alias_method_chain. It is used in a lot of places, like validations.rb around line 221. You see: alias_method_chain :save, :validation alias_method_chain :save!, :validation alias_method_chain :update_attribute, :validation_skipping This creates two aliases as described by the comments: # alias_method_chain :foo?, :feature # # is equivalent to # # alias_method :foo_without_feature?, :foo? # alias_method :foo?, :foo_with_feature? So, in this case save_without_validation points to what save use to point to and now save points to save_with_validation. So, in the code, you will see a call to save and in the stack trace. But the line numbers will be inside save_with_validation. (or foo_with_feature in the general case). foo_with_feature will then usually call foo_without_feature to call the original foo routine. Pretty nifty trick. -- 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 -~----------~----~----~----~------~----~------~--~---
Zach Inglis // LT3media wrote:> >> a.save(false) > => trueA> What''s wrong with calling save_without_validation? Is that /de-facto/ private? B> validations involving unique table keys require lots of database hits, so saving without validation is faster, right? -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---