You can perform a query like this:
Report.joins(:servers).where(:servers => {:company_id => 5})
To me, this is the cleaner solution to raw SQL.
More Related Contents:
- Rails ActiveRecord methods in different places [closed]
- Rails :dependent => :destroy VS :dependent => :delete_all
- ActiveRecord.find(array_of_ids), preserving order
- Rails model without database
- How do I replace accented Latin characters in Ruby?
- Using Rails serialize to save hash to database
- Rails 3: Get Random Record
- Rails 5: ActiveRecord OR query
- How to handle Ruby on Rails error: “Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'”
- Altering the primary key in Rails to be a string
- LEFT OUTER joins in Rails 3
- How to test for (ActiveRecord) object equality
- Rails 3, has_one / has_many with lambda condition
- How do i work with two different databases in rails with active records?
- Rails ActiveRecord: Find All Users Except Current User
- query , can not select column count
- How to use ActiveRecord in a ruby script outside Rails?
- Getting fields_for and accepts_nested_attributes_for to work with a belongs_to relationship
- Regular expressions with validations in RoR 4
- Using helpers in model: how do I include helper dependencies?
- What are the brackets [5.1] after ActiveRecord Migration and how does it work? [duplicate]
- delete_all vs destroy_all?
- Converting an array of objects to ActiveRecord::Relation
- Rails 3.1 limit user created objects
- Store the day of the week and time?
- Is there a way to avoid automatically updating Rails timestamp fields?
- Rails: Overriding ActiveRecord association method
- Rails Object Relationships and JSON Rendering
- What is the difference between Gemfile and Gemfile.lock in Ruby on Rails
- Rails best way to get previous and next active record object