activerecord4-redshift-adapter icon indicating copy to clipboard operation
activerecord4-redshift-adapter copied to clipboard

Needed to replace inspect() and find() - neither worked correctly for me

Open JohnB opened this issue 10 years ago • 1 comments

I don't know if this is the underlying issue for https://github.com/aamine/activerecord4-redshift-adapter/issues/7 , but I've found that when I fetch an object the display from inspect() does not show the ID field - but direct access via obj.id shows it just fine. Thus I over-wrote inspect() for my redshift models to correctly show the ID:

  def inspect
    details = attributes.keys.map {|k| "#{k}: #{(k == 'id' ? self.id : self[k]).inspect}" }.join(", ")
    return "#<#{self.class.name} #{details}>"
  end

Also, the find() method was throwing an exception for me so I patched it to call find_by_id():

    def self.find(integer_id)
      find_by_id(integer_id)
    end

Has anyone else noticed these issues? If so, I'll try to put a better fix into place and do a PR.

JohnB avatar Jun 16 '15 15:06 JohnB

regarding the find method, I think that's the expected behavior http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find

alexperto avatar Nov 12 '15 22:11 alexperto