Skip to content

Instantly share code, notes, and snippets.

# Create the javascripts dir
run 'mkdir public/javascripts'
# pull down jquery, jquery-ui and the appropriate rails driver
run 'curl -L http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js > public/javascripts/jquery.js'
run 'curl -L http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js > public/javascripts/jquery-ui.js'
run 'curl -L http://github.com/rails/jquery-ujs/raw/master/src/rails.js > public/javascripts/rails.js'
MVIM Cheat Sheet:
* auto complete
ctrl+n
or
ctrl+p
* Running Rake for test
:Rake
# Rails 3 generator for miniskirt
# Add the factory_girl gem
append_file 'Gemfile', <<-GEMS
group :test do
gem 'miniskirt'
end
GEMS
# touch the file for storing factories
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
class ImageMagick
def self.palette(image_file, number_of_colours = 5)
image_details = %x(convert #{image_file} +dither -depth 8 -colors #{number_of_colours} -unique-colors txt:-)
image_details.scan(/#[a-z0-9]{6}/i)
end
end
# Factory girl, relaxed.
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
### Basic routes ###
Rails 2:
# singular resource
map.resource :account
# resources with addition member & collection actions
map.resources :games, :member => { :download => :get }, :collection => { :favourites => :get }
Rails 3: