I currently have 2 models - Issue and Responses and i'm trying to add a method on the response model so I can do issue.responses.latest
I'm currently getting undefined method 'issue_id' for #<Class:...
How can I reference the column issue_id from the responses table in my self.latest method?
class Issue < ActiveRecord::Base
has_many :responses
end
class Response < ActiveRecord::Base
belongs_to :issue
def self.latest
select([:id, :user_id, :issue_id, :response, 'MAX(created_at)'])
.where(:issue_id => self.issue_id) <!-- How to reference the issue_id column here?
.group(:issue_id)
end
end