View application_with_config.rb
# needs the "hashie" gem in Gemfile | |
require 'erb' | |
module Movies | |
class Application < Rails::Application | |
settings = ERB.new(IO.read(File.expand_path('../settings.yml', __FILE__))).result | |
mash = Hashie::Mash.new(YAML::load(settings)[Rails.env.to_s]) | |
mash.each do |key, value| |
View gist:669746
class CustomDevise::SessionsController < Devise::SessionsController | |
def create | |
anonymous_cart = Cart.where(:security_hash => session[:security_hash]).last unless session[:security_hash].nil? | |
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") | |
set_flash_message :notice, :signed_in | |
if anonymous_cart && !anonymous_cart.user_id? | |
resource.cart.delete if resource.cart | |
anonymous_cart.update_attribute(:user_id, resource.id) | |
end | |
sign_in_and_redirect(resource_name, resource) |
View gist:669801
add_subscription_cart PUT /cart/add_subscription(.:format) {:controller=>"carts", :action=>"add_subscription"} | |
remove_subscription_cart PUT /cart/remove_subscription(.:format) {:controller=>"carts", :action=>"remove_subscription"} | |
leave_cart GET /cart/leave(.:format) {:controller=>"carts", :action=>"leave"} | |
cart POST /cart(.:format) {:controller=>"carts", :action=>"create"} | |
new_cart GET /cart/new(.:format) {:controller=>"carts", :action=>"new"} | |
edit_cart GET /cart/edit(.:format) {:controller=>"carts", :action=>"edit"} | |
cart GET /cart(.:format) {:controller=>"carts", :action=>"show"} | |
cart PUT /cart(.:format) |
View gist:670460
IndieAisle::Application.routes.draw do | |
resource :cart do | |
member do | |
put 'add_subscription' | |
put 'remove_subscription' | |
get 'leave' | |
end | |
end | |
resource :order | |
match '/checkout' => 'orders#checkout' |
View gist:864379
def mongo=(server) | |
case server | |
when String | |
host, port = server.split(':') | |
@con = Mongo::Connection.new(host, port) | |
@db = @con.db('monque') | |
@mongo = @db.collection('monque') | |
@workers = @db.collection('workers') | |
@failures = @db.collection('failures') | |
@stats = @db.collection('stats') |
View cancel_zencoder_jobs.rb
# jobs deletion has been permanently disabled by Zencoder | |
Zencoder::Job.list.body.map {|j| Zencoder::Job.cancel(j['job']['id'].to_i)} |
View staging.rb
# Configure whenever | |
set :whenever_environment, rails_env | |
set :whenever_output, '/var/www/apps/alt12/current/log/crontab.log' | |
set :whenever_update_flags, "--update-crontab #{whenever_identifier} --set environment=#{whenever_environment}\\&output=#{whenever_output}" # notice the escaping \& passed to the shell |
View gist:1006487
[andrey-mbp ~/projects/rails/alt12-site rails3]$ rake ts:config --trace | |
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3 | |
** Invoke ts:config (first_time) | |
** Invoke thinking_sphinx:configure (first_time) | |
** Invoke thinking_sphinx:app_env (first_time) | |
** Execute thinking_sphinx:app_env | |
** Execute thinking_sphinx:configure | |
Generating Configuration to /Users/akhkharu/projects/rails/alt12-site/config/development.sphinx.conf | |
rake aborted! | |
Association named 'applications_forums' was not found; perhaps you misspelled it? |
View gist:1014249
[andrey-mbp ~/projects/rails/alt12-site rails3]$ rails s | |
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3 | |
=> Booting Mongrel | |
=> Rails 3.1.0.rc2 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
Exiting | |
/Users/akhkharu/.rvm/gems/ruby-1.9.2-head@alt12/gems/actionpack-3.1.0.rc2/lib/action_dispatch/testing/assertions.rb:14:in `<module:Assertions>': uninitialized constant ActionDispatch::Assertions::SelectorAssertions (NameError) | |
from /Users/akhkharu/.rvm/gems/ruby-1.9.2-head@alt12/gems/actionpack-3.1.0.rc2/lib/action_dispatch/testing/assertions.rb:2:in `<module:ActionDispatch>' | |
from /Users/akhkharu/.rvm/gems/ruby-1.9.2-head@alt12/gems/actionpack-3.1.0.rc2/lib/action_dispatch/testing/assertions.rb:1:in `<top (required)>' |
OlderNewer