if params[:status].present?
@user_balance_logs = @user_balance_logs.where(status: params[:status])
enddiv class="form-group col-sm-4">Update years later: instead of a Rake task, for PostgreSQL I just use
rake db:drop db:create
and then
cat somefile.sql | psql name_of_database
Dumping is
CASCADE specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well
Your add_foreign_key calls would look like:
add_foreign_key "projects", "companies", on_delete: :cascade
add_foreign_key "tasks", "projects", on_delete: :cascade
add_foreign_key "task_times", "tasks", on_delete: :cascade
Operator: @>
Description: contains
Example: ARRAY[1,4,3] @> ARRAY[3,1]
Result: t (AKA true)Membership.where('roles @> array[?]', %w[as_champion whatever])
Membership.where('roles @> array[:roles]', :roles => some_ruby_array_of_strings)In the last blogpost about hstore we showed how to enable particular extension. This time is different (maybe easier), because array is Postgres’ data type, not an extension so there’s no need to enable that, because it’s accessible out of the box!
In two previous articles (mentioned in the introduction of this article) we created Book model and appropriate SQL schema. Let’s stick to that and extend it a little bit:
def event(description)
puts "ALERT: #{description}" if yield
end
# 将当前文件夹加入到加载路径中
$: << File.expand_path(File.dirname(__FILE__))
# 1. load 后面的参数不是绝对路径时,load 方法会从 `$:` 中查找文件名为 `event.rb` 的文件
load 'events.rb'It occurs that config/deploy.rb has lock '3.1.0'.
It was enough to change it to '3.2.0' and now it's working.
https://stackoverflow.com/questions/23095881/capistrano-deployment-problems
Failure/Error: it { should have_many(:users) }
ActiveRecord::StatementInvalid:
PGError: ERROR: relation "users" does not exist
LINE 4: WHERE a.attrelid = '"users"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d