Top "Rails-activerecord" questions

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

has_many, belongs_to relation in active record migration rails 4

I have a User model and a Task model. I have not mentioned any relation between them while creating them. …

ruby-on-rails rails-activerecord ruby-on-rails-4 rails-migrations
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
Changing a column type to longer strings in rails

At the first migration, I declared on a column content to be string Activerecord made it to be string(255) according …

ruby-on-rails string postgresql ruby-on-rails-3.1 rails-activerecord
Rails has_one :through association

Rails has a has_one :through association that helps set up a one-to-one association with a third model by going …

ruby-on-rails associations rails-activerecord rails-models
Ruby-on-Rails: Selecting distinct values from the model

The docs: http://guides.rubyonrails.org/active_record_querying.html#selecting-specific-fields Clearly state that: query = Client.select(:name).distinct # => …

ruby-on-rails rails-activerecord
Connecting Rails 3.1 with Multiple Databases

At ShowNearby we have been doing a very big migration to RoR 3.1 from PHP and we are facing several problems …

ruby-on-rails ruby ruby-on-rails-3 rails-activerecord activeresource
How can I overwrite a getter method in an ActiveRecord model?

I'm trying to overwrite a getter method for an ActiveRecord model. I have an attribute called name in the model …

ruby-on-rails ruby rails-activerecord getter-setter
Rails: Validate only on create, or on update when field is not blank

How can I restrict a Rails validation to check only on create OR when the field isn't blank? I'm creating …

ruby-on-rails ruby rails-activerecord
Rails 5: ActiveRecord OR query

How do you do an or query in Rails 5 ActiveRecord? Also, is it possible to chain or with where in …

ruby-on-rails ruby activerecord ruby-on-rails-5 rails-activerecord
How to save a model without running callbacks in Rails

I need to calculate values when saving a model in Rails. So I call calculate_averages as a callback for …

ruby-on-rails ruby-on-rails-3 activerecord ruby-on-rails-3.2 rails-activerecord