On Oct 24, 2:35 pm, "John Barnette" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 24, 2008 at 2:15 PM, Ken Miller <[EMAIL PROTECTED]> wrote:
> > On Oct 24, 12:38 pm, "Michael Koziarski" <[EMAIL PROTECTED]>
> > wrote:
> >> On Fri, Oct 24, 2008 at 6:32 PM, Ken Miller <[EMAIL PROTECTED]> wrote:
>
> >> > when you use a find_or_create_ automatic method with an initializer
> >> > block, the block isn't called on the first run, but is called on
> >> > subsequent runs:
>
> Is this really the desired behavior? I've always considered that block
> equivalent to the AR::Base initializer:
>
> Foo.new do |f|
>   f.thing = default_value
> end
>
> If that's the case, I feel like it *should* be ignored when
> find_or_create_by_n returns a preexisting record.

Sorry, I left that bit of context out of my original message.  In
*both* of my examples, the record does NOT exist.  That is, the first
time the method is called, if the record exists, there's no bug -- the
block isn't called and shouldn't be.  But if, on that first call, the
record doesn't exist, the block is still not called, which is a bug.
This is related to the way AR auto-defines these methods the first
time they're invoked.

K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to