Top "Activerecord" questions

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

Using helpers in model: how do I include helper dependencies?

I'm writing a model that handles user input from a text area. Following the advice from http://blog.caboo.se/…

ruby-on-rails ruby activerecord model
How to execute a raw update sql with dynamic binding in rails

I want to execute one update raw sql like below: update table set f1=? where f2=? and f3=? This SQL …

ruby-on-rails activerecord rawsql
"WARNING: Can't mass-assign protected attributes"

I have used RESTful techniques to generate a model (in fact, I am using Devise gem, which does that for …

ruby-on-rails activerecord devise
how to add records to has_many :through association in rails

class Agents << ActiveRecord::Base belongs_to :customer belongs_to :house end class Customer << ActiveRecord::Base has_…

ruby-on-rails activerecord has-many-through
Saving multiple objects in a single call in rails

I have a method in rails that is doing something like this: a = Foo.new("bar") a.save b = Foo.…

ruby-on-rails activerecord data-access
Using Rails serialize to save hash to database

I'm try to save a hash mapping ids to a number of attempts in my rails app. My migration to …

ruby-on-rails ruby serialization activerecord
codeigniter active record left join

I have 3 mysql tables. Table 1 user id | name Table 2 emails id | email Table 3 user_email user_id | email_id I …

php codeigniter activerecord left-join
Yii2 How to perform where AND or OR condition grouping?

I am new to Yii-2 framework. How can i achieve following query in Yii-2 framework using activeQuery and models. SELECT * …

php mysql activerecord yii yii2
How to do a LIKE query in Arel and Rails?

I want to do something like: SELECT * FROM USER WHERE NAME LIKE '%Smith%'; My attempt in Arel: # params[:…

ruby-on-rails activerecord arel
When to use a "has_many :through" relation in Rails?

I am trying to understand what has_many :through is and when to use it (and how). However, I am …

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