Top "Activerecord" questions

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

Safe ActiveRecord like query

I'm trying to write LIKE query. I read that pure string quires aren't safe, however I couldn't find any documentation …

ruby activerecord ruby-on-rails-4
Find rows with multiple duplicate fields with Active Record, Rails & Postgres

What is the best way to find records with duplicate values across multiple columns using Postgres, and Activerecord? I found …

ruby-on-rails postgresql activerecord
Rails 4: find all records

Now that ActiveRecord::Relation#all is deprecated in Rails 4, how are you supposed to iterate all records? Used to be …

activerecord ruby-on-rails-4
When do I use save!, create! and update_attributes! in Rails?

I'm trying to figure out when to use the bang! versions for saving and updating records? I've read and heard …

ruby-on-rails activerecord transactions
ActiveRecord Find By Year, Day or Month on a Date field

I have an ActiveRecord model that has a date attribute. Is it possible to utilize that date attribute to find …

ruby-on-rails ruby-on-rails-3 activerecord rails-activerecord
In rails, how can I find out what caused a .save() to fail, other than validation errors?

I have an ActiveRecord model which is returning true from valid? (and .errors is empty), but is returning false from …

ruby-on-rails activerecord
How to determine if a record is just created or updated in after_save

The #new_record? function determines if a record has been saved. But it is always false in the after_save …

ruby-on-rails activerecord activemodel
Do rails rake tasks provide access to ActiveRecord models?

I am trying to create a custom rake task, but it seems I dont have access to my models. I …

ruby-on-rails activerecord rake task
Destroy/Remove database in Rails

Is it possible to completely remove the database and all migration records etc from an existing application so I can …

database ruby-on-rails-3 sqlite activerecord rails-migrations
Overriding id on create in ActiveRecord

Is there any way of overriding a model's id value on create? Something like: Post.create(:id => 10, :title => …

ruby-on-rails activerecord