Ruby
From Wiki2
goto /users/tim/code/ruby
- rails new appname
- sets up directory system
- bundle install
- installs gems
- .gitignore
- installed with rails new
- git init
- starts new repository
- git add .
- git status; tells you what branch you are on and if you have stuff to commit
- git commit
- commits change locally
- git log
- of commits
on github
- new repository
back on local machine
- git remote add origin git@github.com
- mckennatim/rubyapp2.git: this line is given in github
- git push -u origin master
- get checkout -b modify-README
- creates a new branch
- mate README
- now in new branch
- git mv README README.markdown
- mate README.markdown
- git commit -am "improve readme"
- commit locally all, message
- git checkout master
- moves back to master branch
- git merge modify-README
- bringes changes of the modify-README branch into the master branch
- git push
- all you need to push it back to github
to use hosting site
- heroku
- heroku keys:add
- heroku create
- git push heroku master
- git mergetool
- to resolve conflicts
- heroku wouldn't work with ror3
- fixed config/application.rb to read..
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
#require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
require "active_record"
- kill rail server; lsof -wni tcp
- 3000, kill -9 PID
ruby syntax
>> nil.empty?
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
>> nil.to_s.empty? # Message chaining
=> true
It’s worth noting that the nil object is special, in that it is the only Ruby object that is false in a boolean context, apart from false itself:
>> if nil
>> true
>> else
>> false # nil is false
>> end
=> false
# 0 (and everything other than nil and false itself) is true
>> "foo bar baz".split # Split a string into a three-element array
=> ["foo", "bar", "baz"]
>> "fooxbarxbazx".split('x')
=> ["foo", "bar", "baz"]
>> a.sort
=> [8, 17, 42]
>> a.reverse
=> [17, 8, 42]
>> a.shuffle
=> [17, 42, 8]