When is touch for a belongs_to in Rails triggered?

From: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html :touch If true, the associated object will be touched (the updated_at/on attributes set to now) when this record is either saved or destroyed. If you specify a symbol, that attribute will be updated with the current time in addition to the updated_at/on attribute. belongs_to :company, :touch => true belongs_to :company, :touch => :employees_last_updated_at

How to use Rails 4 strong parameters with has_many :through association?

Keep in mind that the name you give to your strong parameters (employees, employee_ids, etc.) is largely irrelevant because it depends on the name you choose to submit. Strong parameters work no “magic” based upon naming conventions. The reason https://gist.github.com/leemcalilly/a71981da605187d46d96 is throwing an “Unpermitted parameter” error on ’employee_ids’ is because it is expecting an array … Read more

Yii2 : Active Record add Not In condition

Well all query operands seems now merged within in yii\db\QueryInterface::Where() per documentation an In condition can now be added using something like $query = MyModel::find()->where([‘attribute’=>$array]); for a not In condition it is slightly different format $query = MyModel::find()->where([‘not in’,’attribute’,$array]);

How to list of all the tables defined for the database when using active record?

Call ActiveRecord::ConnectionAdapters::SchemaStatements#tables. This method is undocumented in the MySQL adapter, but is documented in the PostgreSQL adapter. SQLite/SQLite3 also has the method implemented, but undocumented. >> ActiveRecord::Base.connection.tables => [“accounts”, “assets”, …] See activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:21, as well as the implementations here: activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:412 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:615 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:176

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)