.where.not(column_name: nil)Yay!
Showing posts with label ActiveRecord. Show all posts
Showing posts with label ActiveRecord. Show all posts
Tuesday, January 28, 2014
Rails4's Active Record where not nil
Since Rails 4.0 no more .where('column_name IS NOT NULL'). Instead, we now can use
Friday, October 28, 2011
[Heroku] Access Rails's model in migration, heroku rake db:migrate, uninitialized constant
I wanted to use Rails's migration to add new column to a table and fill this column with default value.
Then I deployed to Heroku and run;
The way to solve this issue(don't know why) is to open up the class inside migration file like this;
Note: Rails 3.1.0
add_column :students, :student_id, :integer
Student.all.each { |s| s.update_attributes!(:student_id => s.id+10000) }I run this locally.
rake db:migrateIt worked without any problem.
Then I deployed to Heroku and run;
heroku rake db:migrateI found this error.
uninitialized constant AddStudentIdToStudents::StudentAfter googling for a while, I found this blog post Heroku Migration Fails to Update Attributes: reset_column_information
The way to solve this issue(don't know why) is to open up the class inside migration file like this;
This works for me.class AddStudentIdToStudents < ActiveRecord::Migrationclass Student < ActiveRecord::Base; enddef changeadd_column :students, :student_id, :integerStudent.all.each { |s| s.update_attributes!(:student_id => s.id+10000) }endend
Note: Rails 3.1.0
Subscribe to:
Posts (Atom)
Collectd PostgreSQL Plugin
I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...
-
sudo su postgres supply your Mac password modify /Library/PostgreSQL/9.x/data/pg_hba.conf from local all all md5 to local all all ...
-
Put your cursor on the text box of the post/comment you want to indent Go to the menubar at the top of the screen Edit > Emoji & ...
-
I ran to this error the other day when I tried to export a dump file from a slave Postgres database. cpg_dump: Dumping the contents of ta...