Due to the rails2.x is not compatible wtih RubyGem > 1.6, need downgrade RubyGem if run rails2.x app
gem uninstall rubygems-update
gem install rubygems-update -v 1.4.2
update_rubygems| namespace :delayed_job do | |
| task :setup do | |
| puts capture %Q(cd #{deploy_to}/current/ && RAILS_ENV=production script/rails runner 'Delayed::Backend::Mongoid::Job.create_indexes') | |
| end | |
| task :start do | |
| puts capture %Q(cd #{deploy_to}/current/ && RAILS_ENV=production script/delayed_job start) | |
| end | |
| task :stop do |
| namespace :book_item do | |
| task :free_all_if_due => :environment do | |
| Book.free_book_items_if_due | |
| puts 'Free the due book_item successfully' | |
| end | |
| end |
| args **/*.txt | |
| argsdo %s/oldword/newword/gc | |
| /oldword/newword/# to disable the ignorecase options |
| file = File.join(Rails.root, 'log/markdown.log') | |
| File.new(file, 'w+') unless File.exist?(file) | |
| logger = Logger.new(file) | |
| logger.info("#{Time.now}: Share##{_id}'s price is from #{latest_price} to #{new_price}") | |
| logger.close |
| --export | |
| mysql -u user -p password database_name > export.sql | |
| mysql -u user -p password database_name table_name > export.csv | |
| --import | |
| mysql -u user -p password | |
| source export.sql |
| f = lambda {|x, y=1| puts(x+y) } | |
| f = ->(x, y =1) { puts(x+y) } |
| require 'forwardable' | |
| class A | |
| extend Forwardable | |
| def initialize | |
| @arr = Array.new | |
| end | |
| def_delegator :@arr, :push, :add |
| > DB_STRUCTURE=db/null_schema.sql rake db:structure:dump | |
| class NullMigration < ActiveRecord::Migration | |
| def up | |
| file_data = File.read('db/migrate/null_schema.sql') | |
| ActiveRecord::Base.connection.execute file_data | |
| end | |
| def down |
| $ rspec --format MacVimFormatter --color spec |
Due to the rails2.x is not compatible wtih RubyGem > 1.6, need downgrade RubyGem if run rails2.x app
gem uninstall rubygems-update
gem install rubygems-update -v 1.4.2
update_rubygems