where("created_at > :t1 and created_at < :t2",
:t1 => start,
:t2 => start + 7.days
has_many :posts, :extend => FindWeeklyExtension
Over time, though, classes might start to include many modules:
# several modules
has_many :posts, :extend => [...]
You might notice that you only need an extension or module to exist in
one particular context:
So it'd be cleaner not to have that in the class, and instead to do
something like this:
has_many :posts # we refactored :extend => FindWeeklyExtension ...
posts.extend FindWeeklyExtension # ... and moved it here
However, this doesn't work:
NoMethodError: undefined method `where' for #<Array:
So, is there a good way to extend an association, but only for a
specific instance's association?
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 firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.