Software Development
Pages
(Move to ...)
Home
About
Contact
▼
Thursday, February 20, 2014
SimpleDelegator in Ruby
require 'delegate'
class User
def born_on
'July 21'
end
end
class UserDecorator < SimpleDelegator
def birth_year
born_on
end
end
decorated_user = UserDecorator.new(User.new)
p decorated_user.birth_year #=> July 21
Friday, February 14, 2014
psych.rb in `parse': found a tab character that violate intendation while scanning a plain scalar at
You will not be able to go the rails console. Go to the root directory of the rails project and fire up an irb session:
1. require 'yaml'
2. YAML::ENGINE.yamler = 'psych'
3. YAML.load_file('config/your-config-file.yml')
Autocorrect yaml file syntax errors:
s
.
gsub!
(
/\t/
,
' '
)
This will reproduce the problem. See the line number of row to find the syntax error. Fix it by changing the tab to space.
‹
›
Home
View web version