Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration with Occurrence to Arel #168

Closed
avit opened this issue May 7, 2013 · 0 comments
Closed

Add integration with Occurrence to Arel #168

avit opened this issue May 7, 2013 · 0 comments

Comments

@avit
Copy link
Collaborator

avit commented May 7, 2013

Changing to use the IceCube::Occurrence class as a wrapper for times means having to map them back to times when using with ActiveRecord & Arel:

Model.where("time IN ?", schedule.occurrences)
# => TypeError (Cannot visit IceCube::Occurrence)

Model.where("time IN ?", schedule.occurrences.map(&:to_time))
# => [#<Model id: 1, time: ...>]

It would be nice to have Occurrences work transparently as Time objects. Need to investigate further... Can we override #class without making bad stuff happen?

Adding this workaround in a rails initializer makes it work for now:

class Arel::Visitors::ToSql
  def visit_IceCube_Occurrence(value)
    quoted(value.to_time)
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant