Top "Activerecord" questions

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

Active Record - Find records which were created_at before today

I want to get all records where the created_at field is less than today (a date). Is there anything …

ruby activerecord
validation custom message for rails 3

Rails has introduced new way to validate attributes inside model. When I use validates :title, :presence => true it works …

ruby-on-rails ruby ruby-on-rails-3 validation activerecord
What's the difference between belongs_to and has_one?

What is the difference between a belongs_to and a has_one? Reading the Ruby on Rails guide hasn't helped …

ruby-on-rails activerecord
ActiveRecord - querying polymorphic associations

I am using polymorphic associations to track Comments in my project. All very straight forward stuff. The problem I have …

ruby-on-rails ruby activerecord polymorphic-associations
CodeIgniter: INSERT multiple records without cycle

It's possible to use multiple INSERT records in CodeIgniter Active Record without for, foreach and etc. ? My current code: foreach($…

codeigniter activerecord codeigniter-2
Yii selecting only specified attributes in array

I often face this problem.. Lets say ..In blog application, I need to email all the active users.. What I …

php activerecord yii
How to initialize an ActiveRecord with values in Rails?

In plain java I'd use: public User(String name, String email) { this.name = name; this.email = f(email); this.admin = …

ruby-on-rails activerecord ruby-on-rails-3.2
Using ActiveRecord, is there a way to get the old values of a record during after_update

Setup using a simple example: I've got 1 table (Totals) that holds the sum of the amount column of each record …

ruby-on-rails activerecord model callback
Use a scope by default on a Rails has_many relationship

Let's say I have the following classes class SolarSystem < ActiveRecord::Base has_many :planets end class Planet < ActiveRecord::…

ruby-on-rails-3 activerecord has-many
ActiveRecord.find(array_of_ids), preserving order

When you do Something.find(array_of_ids) in Rails, the order of the resulting array does not depend on …

ruby-on-rails ruby activerecord