Top "Activerecord" questions

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

How to chain scope queries with OR instead of AND?

I'm using Rails3, ActiveRecord Just wondering how can I chain the scopes with OR statements rather than AND. e.g. …

ruby-on-rails ruby-on-rails-3 activerecord rails-activerecord
How to convert ActiveRecord results into an array of hashes

I have an ActiveRecord result of a find operation: tasks_records = TaskStoreStatus.find( :all, :select => "task_id, store_name, …

arrays activerecord hash
Get only records created today in laravel

How do I use the created_at field to get only the records that were created today and no other …

mysql date activerecord where laravel-5.1
belongs_to through associations

Given the following associations, I need to reference the Question that a Choice is attached through from the Choice model. …

ruby-on-rails ruby-on-rails-3 activerecord
Is there a way to get a collection of all the Models in your Rails app?

Is there a way that you can get a collection of all of the Models in your Rails app? Basically, …

ruby-on-rails activerecord collections model
delete_all vs destroy_all?

I am looking for the best approach to delete records from a table. For instance, I have a user whose …

ruby-on-rails ruby database activerecord
Rails find_or_create_by more than one attribute?

There is a handy dynamic attribute in active-record called find_or_create_by: Model.find_or_create_by_<attribute&…

ruby-on-rails activerecord model many-to-many dynamic-attributes
How do you discover model attributes in Rails?

I am finding it difficult to easily see what attributes/properties exist on all of my model classes since they …

ruby-on-rails activerecord
Rails filtering array of objects by attribute value

So I perform a query to the db and I have a complete array of objects: @attachments = Job.find(1).attachments …

ruby-on-rails activerecord
Rails create or update magic?

I have a class called CachedObject that stores generic serialised objects indexed by key. I want this class to implement …

ruby-on-rails activerecord