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
# Between those alternatives I'd go with this one. | |
# | |
# Ruby has open classes, there is nothing wrong about embracing them. Even Rails that used to | |
# create modules and mix them into the classes has decided to change it on rails3 and simply | |
# open the classes and add the methods. | |
# | |
# It's simple, and it works. Of course you shouldn't be adding stuff that are specific to | |
# your application's business logic. | |
class Fixnum | |
def to_bit_array |
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 < ActiveRecord::Base | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :confirmable, :lockable and :timeoutable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :token_authenticatable, | |
:oauthable | |
# Setup accessible (or protected) attributes for your model | |
attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :has_username, :is_admin, :profile | |
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 RomanNumeral | |
VALUE_MAPPER = [['M', 1000], ['D', 500], ['L', 50], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]] | |
def roman num | |
output = '' | |
while num > 0 | |
VALUE_MAPPER.each do |letter, letter_value| | |
num_of_letters = (num / letter_value) |
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
groups = Rails.groups(assets: %w(development test)) | |
unless Rails.env.production? | |
user = `cd "#{Rails.root}" && git config user.email`.chomp | |
groups << user unless user.blank? | |
end | |
Bundler.require(*groups) |