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
# config/initializers/activity_order.rb | |
ACTIVITIES = [PersonalValues, PersonActions, SomeOther] | |
# config/initializer/array.rb | |
class Array | |
def relative_index(item, idx) | |
self[index(item) + idx] | |
end | |
def next(item) |
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 Person < ActiveRecord::Base | |
validates :name, :presence: true, :if: :authed? | |
validates :name, :presence: true, :if: :unaccepted? | |
validates :name, :presence: true, :if: :accepted? | |
state_machine :state, :initial => :authed do | |
event :filled_out_profile do | |
transition :authed => :unaccepted | |
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
# = Icebox : Caching for HTTParty | |
# | |
# Cache responses in HTTParty models [http://github.com/jnunemaker/httparty] | |
# | |
# === Usage | |
# | |
# class Foo | |
# include HTTParty | |
# include HTTParty::Icebox | |
# cache :store => 'file', :timeout => 600, :location => MY_APP_ROOT.join('tmp', 'cache') |
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 Numeric | |
def spaces | |
self * " " | |
end | |
end | |
p 128.spaces |