Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Simple monkey patch would work
- module ActiveRecord
- Base.send :attr_accessor, :_row_
- module Associations
- class JoinDependency
- JoinBase && class JoinPart
- def instantiate_with_row(row, *args)
- instantiate_without_row(row, *args).tap { |i| i._row_ = row }
- end
- alias_method_chain :instantiate, :row
- end
- end
- end
- end
- #Then you can get a column value from a row:
- Post.includes(:comments).select("posts.*, 1 as testval").first._row_['test_val']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement