marnen / positron

Don't leak ActiveRecord details into your Rails models!
MIT License
0 stars 0 forks source link

Define ActiveRecord associations #6

Open marnen opened 10 years ago

marnen commented 10 years ago

As a user I can define ActiveRecord associations and other options on my Positron DB classes So that I can take advantage of associations in Positron

Interface idea:

class Blog # not ActiveRecord
  include Positron

  db do
    has_many :posts
    acts_as_list
  end

  def first_post
    db.posts.order(:position).first
  end
end
marnen commented 10 years ago

Should the objects returned by the association be ActiveRecord objects or not? I could see this working either way. On the one hand, I do want to be able to do db.posts.order(:position).first as shown in the example, but on the other hand, I'd like to be able to call methods on the associated objects without touching the ActiveRecord stuff.

Hmm. Perhaps this means that we need to remove Positron from associations immediately after the ARel query has been executed. That way we get ARel for the query, but the object comes through to the host as simply a plain Ruby object.

marnen commented 9 years ago

Putting on hold for #5.

marnen commented 9 years ago

5 is done. Unblocked.