Struggling with formulating a simple join. I am pretty new to
activerecord and ruby.I have a database with tables ‘bugs’ and
‘longdesc’. Here are my classes:
class Bug < ActiveRecord::Base
has_many :longdescs
end
class Longdesc < ActiveRecord::Base
belongs_to :bugs
end
I am trying to formulate a simple query joining these two tables but am
having no luck. I can get a query without joining to work fine. For
example, the following works perfectly:
Thanks Troy. It is ActiveRecord 3. Here is the solution that worked for
me.
bugs =
Bug.joins(:longdescs).select(“bugs.bug_id,bugs.bug_status,bugs.priority,bugs.bug_severity,bugs.short_desc,longdescs.thetext”).where(:bug_id
=> ARGV)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.