This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
see http://github.com/imajes/rails-template/tree/master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#These all pass the specs in post_create_with_stubble_spec.rb, but not necessarily the other ones | |
def create | |
@registration = Registration.new(params[:registration]) | |
if @registration.save | |
redirect_to registrations_path | |
else | |
render :action => 'new' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
# url dsl -- the ultimate url dsl! | |
# | |
# You just can't beat this: | |
# | |
# $ irb -r url_dsl | |
# >> include URLDSL | |
# => Object | |
# >> http://github.com/defunkt.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = ARGV.shift || "~/Music/iTunes/iTunes Music Library.xml" | |
albums = [] | |
d = {} | |
IO.foreach(File.expand_path(file)) do |line| | |
if line =~ /<dict/ | |
d.clear | |
elsif line =~ /<key>(Artist|Album)<\/key><.*?>(.*)<\/.*?>/ | |
key = $1.downcase.first.intern | |
d[key] = $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include Mongoid::Document | |
references_one :best_friend, :class_name => "Person" | |
references_one :worst_enemy, :class_name => "Person" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "stateful" | |
class Folder < ActiveRecord::Base | |
include Stateful | |
# ... | |
stateful do | |
state :active | |
state :inactive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task to launch multiple Resque workers in development/production with simple management included | |
require 'resque/tasks' # Require Resque tasks | |
namespace :workers do | |
# = $ rake workers:start | |
# | |
# Launch multiple Resque workers with the Rails environment loaded, | |
# so they have access to your models, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/dev/redstamp/redstamp.com-app[master]$ cap production deploy | |
<snip> | |
triggering start callbacks for `production' | |
* executing `require_recipes' | |
triggering before callbacks for `require_recipes' | |
* executing `validate_required_variables' | |
* executing `production' | |
triggering start callbacks for `deploy' | |
* executing `multistage:ensure' | |
* executing `require_recipes' |