Top "Activerecord" questions

Active Record is a pattern that combines domain logic with storage abstraction in single object.

Yii2 : Active Record add Not In condition

What is the active Record way of adding IN condition to an active Query in yii 1.x you could use …

activerecord yii yii2
Override ActiveRecord attribute methods

An example of what I'm talking about: class Person < ActiveRecord::Base def name=(name) super(name.capitalize) end def …

ruby-on-rails oop activerecord
"Order by" result of "group by" count?

This query Message.where("message_type = ?", "incoming").group("sender_number").count will return me an hash. OrderedHash {"1234"=>21, "2345"=>11, "3456"=>63, "4568"=&…

ruby-on-rails ruby-on-rails-3 activerecord sql-order-by
Rails: validate uniqueness of two columns (together)

I have a Release model with medium and country columns (among others). There should not be releases that share identical …

ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 activerecord rails-activerecord
LEFT OUTER joins in Rails 3

I have the following code: @posts = Post.joins(:user).joins(:blog).select which is meant to find all posts and …

ruby-on-rails ruby activerecord
How to list of all the tables defined for the database when using active record?

How do I get a list of all the tables defined for the database when using active record?

activerecord
Find all records which have a count of an association greater than zero

I'm trying to do something that I thought it would be simple but it seems not to be. I have …

sql ruby-on-rails ruby-on-rails-3 activerecord
How do I turn on SQL debug logging for ActiveRecord in RSpec tests?

I have some RSpec tests for my models and I would like to turn on SQL ActiveRecord logging just like …

ruby-on-rails ruby activerecord rspec-rails
Rails - Validate Presence Of Association?

I have a model A that has a "has_many" association to another model B. I have a business requirement …

ruby-on-rails ruby-on-rails-3 validation activerecord
Rails: Why does find(id) raise an exception in rails?

Possible Duplicate: Model.find(1) gives ActiveRecord error when id 1 does not exist If there is no user with an id …

ruby-on-rails activerecord