Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
| Ctrl+C | copy current line (if no selection) |
| Ctrl+X | cut current line (if no selection) |
| Ctrl+⇧+K | delete line |
| Ctrl+↩ | insert line after |
| $ ./benchmark.rb 1000 | |
| user system total real | |
| # Inserting 1000 rows normally | |
| insertion 0.290000 0.030000 0.320000 ( 0.396852) | |
| # Updating 1000 rows normally | |
| updating 0.280000 0.020000 0.300000 ( 0.381354) | |
| # Updating 100 rows, adding 10 columns each | |
| insertion/10 0.280000 0.020000 0.300000 ( 0.410743) |
| require 'active_record' | |
| require 'activerecord-import' | |
| require 'benchmark' | |
| require 'pg' | |
| include ActiveRecord | |
| Base.establish_connection adapter: 'postgresql', | |
| encoding: 'unicode', | |
| pool: 5, |
| require "pg" | |
| require "redis" | |
| words = File.read("/usr/share/dict/words").split "\n" | |
| pgconn = PGconn.open :dbname => "test_hstore", :port => 5433, :user => "test_user", :password => "changeme" | |
| redis = Redis.new | |
| reps = [1,10,100,1000,10000] | |
| pg_inserts = [] | |
| pg_selects = [] | |
| redis_sets = [] |
| <%= semantic_form_for @parent do |a| %> | |
| <%= a.inputs "Family Details" do %> | |
| <%= a.input :name %> | |
| <%= a.input :user %> | |
| <%= a.input :region %> | |
| <% end %> | |
| <%= a.inputs "Children" do %> | |
| <table> |
Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
| Ctrl+C | copy current line (if no selection) |
| Ctrl+X | cut current line (if no selection) |
| Ctrl+⇧+K | delete line |
| Ctrl+↩ | insert line after |
| ActiveAdmin.register_page "Dashboard" do | |
| menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") } | |
| content :title => proc{ I18n.t("active_admin.dashboard") } do | |
| # div :class => "blank_slate_container", :id => "dashboard_default_message" do | |
| # span :class => "blank_slate" do | |
| # span "Welcome to Active Admin. This is the default dashboard page." | |
| # small "To add dashboard sections, checkout 'app/admin/dashboards.rb'" | |
| # end |
| ActiveAdmin::Dashboards.build do | |
| # Add this section in your dashboard... | |
| section "Background Jobs" do | |
| now = Time.now.getgm | |
| ul do | |
| li do | |
| jobs = Delayed::Job.where('failed_at is not null').count(:id) | |
| link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red' | |
| end |
| # config/initializers/active_admin.rb | |
| ActiveAdmin.setup do |config| | |
| config.current_user_method = :current_user | |
| config.authentication_method = :authenticate_user! | |
| config.before_filter :admin_role_filter | |
| end | |
| # Adding all recource names to Permissions table after ActiveAdmin is loaded |
##References
##Create Rails App
command to make new directory:
mkdir AppName
| # blog post: | |
| # Before using this initializer, you must set up Cancan. First, add the gem to your Gemfile: | |
| # | |
| # gem 'cancan' | |
| # | |
| # Next, generate and edit an Ability class: | |
| # | |
| # rails generate cancan:ability | |
| # |