On Thu, Apr 16, 2009 at 11:26, Ryan Bates <[email protected]> wrote:
>
> I am building a Rails plugin which is somewhat similar to named scopes
> and therefore behaves like an array. However it isn't a subclass of
> Array
I see now that the current check is pretty ugly:
if Array === partial_path ||
(defined?(ActiveRecord) &&
(ActiveRecord::Associations::AssociationCollection === partial_path ||
ActiveRecord::NamedScope::Scope === partial_path))
render_partial_collection(options.except(:partial).merge(:collection =>
partial_path))
How about simply:
if partial_path.respond_to?(:each) and not String === partial_path
Are there use cases where models themselves will respond to "each", or where
this approach could otherwise backfire?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---