Skip to content

Instantly share code, notes, and snippets.

View hiendinhngoc's full-sized avatar
🐉
Focusing

Dinh Ngoc Hien hiendinhngoc

🐉
Focusing
View GitHub Profile
/home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'mysql2'. (Bundler::GemRequireError)
	from /home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
	from /home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
	from /home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
	from /home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
	from /home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
	from /home/hien/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
	from /home/hien/rails_projects/childfoot/peco_blog/config/applicatio

this is my controller:

module Admin
  class StatsController < Admin::BaseController
    def index
      @q = User.ransack(params[:q])
      @users = @q.result(distinct: true).page(params[:page]).per(params[:per] || DEFAULT_PER_PAGE)
    end
  end
end
  • Login to postgres:
    psql -U postgres (Mac OS)
    sudo -u postgres psql (Ubuntu)
  • List databases:
    psql -l
  • Create user and password:
    psql -U postgres -c "CREATE USER hien WITH PASSWORD '119201my'"
  • Show roles:
    select * from pg_roles;