View database.yml
1 2 3 4 5 6 7 8 9 10
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: postgresql #changed this
encoding: utf8
database: hosted_development #changed this
username: alan #changed this
password: MlwhvC4R
 
# Warning: The database defined as "test" will be erased and
View Generating Model Relationships
1 2
# This creates Review model, controller, columns, and indexed movie_id column, and a one-to-many relationship between reviews movies.
rails g resource Review name:string stars:integer comment:text movie:references --no-test-framework
View form_for
1 2 3 4 5 6 7 8 9 10
# Put this in the form_for loop after "do"
<%= render 'shared/errors', object: @object_name %>
 
# Then in the shared/errors partial put:
<% if object.errors.any? %>
<section id="errors">
<header>
<h2>
Oops! The <%= object.titleize.downcase %> could not be saved.
</h2>
View Duplicates_Removed.rb
1 2
dups = [8,1,2,1,4,4,5,7,8,5]
trimmed = dups.uniq
View CSV_generate.rb
1 2 3 4 5 6 7 8 9
require 'csv'
outfile = File.open('csvout.csv', 'wb')
CSV::Writer.generate(outfile) do |csv|
csv << ['c1', nil, 5]
csv << ['c2', 1, 2, 'abc']
end
outfile.close
 
#also read the file and print
View match_and_print.rb
1 2 3
lines = File.new('foo.txt', 'r').select do |line|
line =~ /pattern/
end
View strip_each_line.rb
1 2 3
lines = File.new('foo.txt', 'r').collect() do |line|
line.strip()
end
View One Line at a Time.rb
1 2 3 4
File.new('foo.txt', 'r').each() do |line|
# Process the line
print line
end
View One Line at a Time.rb
1 2 3 4
File.new('foo.txt', 'r').each() do |line|
# Process the line
print line
end
View css_resources.md

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

Something went wrong with that request. Please try again.