Top "Rails-activerecord" questions

The implementation of object-relational mapping (ORM) using the Active Record pattern in the Ruby on Rails framework.

Making the rails console output a little more pretty

a rails console output looks like this: User.all => [#<User id: 1, name: "Michael Hartl", email: "[email protected]", …

ruby-on-rails rails-activerecord
Deprecation warning when using has_many :through :uniq in Rails 4

Rails 4 has introduced a deprecation warning when using :uniq => true with has_many :through. For example: has_many :donors, :…

ruby-on-rails activerecord rails-activerecord ruby-on-rails-4
Clean way to find ActiveRecord objects by id in the order specified

I want to obtain an array of ActiveRecord objects given an array of ids. I assumed that Object.find([5,2,3]) Would …

ruby-on-rails sqlite activerecord find rails-activerecord
ActiveRecord OR query Hash notation

I know there are 3 main notations for supplying arguments to the where ActiveRecord method: Pure String Array Hash Specifying and …

ruby-on-rails ruby-on-rails-4 activerecord rails-activerecord ruby-on-rails-5
undefined method `key?' for nil:NilClass

I'm new to Rails and was following Ryan Bate's tutorial on how to make a simple authentication system (http://railscasts.…

ruby-on-rails authentication ruby-on-rails-3.2 rails-activerecord railscasts
Cascade delete in Ruby ActiveRecord models?

I was following the screencast on rubyonrails.org (creating the blog). I have following models: comment.rb class Comment < …

ruby-on-rails rails-activerecord database-relations
Rails first_or_create ActiveRecord method

What does the first_or_create / first_or_create! method do in Rails? According to the documentation, the method "has …

ruby-on-rails ruby activerecord rails-activerecord
Rails ActiveRecord: validate single attribute

If there is a way I can validate single attribute in Rails? Something like: ac_object.valid?(attribute_name) I'm …

ruby-on-rails validation rails-activerecord
How do I add migration with multiple references to the same model in one table? Ruby/Rails

How do I create a migration with two fields that reference the same table? I have tables A, and image. …

ruby-on-rails ruby rails-activerecord rails-migrations
Group, count, having, and order by in Rails

I have a table: people with a column named: age. How can I get a count of the people with …

ruby-on-rails rails-activerecord