simple.rb
code = <<END
class Adder
def add_two(x)
x+2
end
end
# Our own variable where we deploy this app to | |
deploy_to = "/srv/example.com" | |
current_path = "#{deploy_to}/current" | |
shared_path = "#{deploy_to}/shared" | |
shared_bundler_gems_path = "#{shared_path}/bundler_gems" | |
# See http://unicorn.bogomips.org/Sandbox.html | |
# Helps ensure the correct unicorn_rails is used when upgrading with USR2 | |
Unicorn::HttpServer::START_CTX[0] = "#{shared_bundler_gems_path}/bin/unicorn_rails" |
Rails.configuration.cache_classes = true | |
Rails.configuration.threadsafe! | |
Rails.configuration.allow_concurrency = true | |
require "#{Rails.root}/test/factories" | |
Dir.glob(File.join(Rails.root, 'app', '{lib,app}', '*.rb')).each{|f| require f} | |
Rails.application.eager_load! | |
puts "Creating users..." | |
users = [] |
simple.rb
code = <<END
class Adder
def add_two(x)
x+2
end
end
#require 'rack/request' | |
# Rack middleware to decode a `Transfer-Encoding: chunked` HTTP request. | |
# | |
# USAGE NOTE: | |
# | |
# Some HTTP servers (Webrick and Unicorn/Rabinbows/Zbatery) already decode the | |
# chunked stream, but they leave the 'Transfer-Encoding' header and don't bother | |
# to add a 'Content-Length' header, which causes rails ActionDispatch::Request | |
# to not parse the whole request body. |
Inspired by activeadmin_addons and its Enum Integration I want to make similar functionality for AASM by letting users change events depending on their abilities and available events/statuses in model.
Sorry i have no time to create an addon right now for this gem but i will try to do it soon. Feel free to modify, use it and integrate. Ask me any question if you need!
Gem: ActiveAdmin,
# https://github.com/ddollar/forego | |
ASSET_HOST=localhost:3000 | |
APPLICATION_HOST=localhost:3000 | |
BCRYPT_COST=12 | |
PORT=3000 | |
RACK_ENV=development | |
RACK_MINI_PROFILER=0 | |
SECRET_KEY_BASE=development_secret | |
EXECJS_RUNTIME=Node |
If you need to manipulate existing data when your code is deployed, there are two main ways to do it:
Regardless of the method you use, make sure to test your migrations before submitting them.
# Dealing with namespaces in Nokogiri. | |
# | |
# First thing you must do is abandon what you're used to with Builder, | |
# namespaces aren't just attributes on an element, they uniquely identify | |
# what sort of element you are building and, as such, you are better off | |
# specifying them manually. | |
# | |
# The key here is accessing the Nokogiri::XML::Element being built with | |
# b.parent, then you can set the namespace (distinguished by an element | |
# with a prefix such as "soap12:Envelope") or add a default namespace |
def stuff | |
yield action: 'Boom', schedule: '7PM', color: :red, debug: true | |
end | |
# When a hash is yielded to a block, we can used named arguments to | |
# capture the keys we want, and an anonymous splat to ignore | |
# everything else | |
stuff { |action:, schedule:, **| p "Doing #{action} at #{schedule}" } | |
# |
task :environment do | |
require './dj-sinatra' | |
end | |
namespace :jobs do | |
desc "Clear the delayed_job queue." | |
task :clear => :environment do | |
Delayed::Job.delete_all | |
end |