This file contains hidden or 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
## app/assets/javascripts/tenon/controllers/product_updates.js.coffee | |
Tenon.dispatcher.route 'tenon/product_updates#index', -> | |
new Tenon.features.AdvancedSearch | |
## app/controllers/tenon/product_updates_controller.rb | |
before_filter :initialize_advanced_search_params, only: :index | |
def index |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
# 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> |
This file contains hidden or 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
dups = [8,1,2,1,4,4,5,7,8,5] | |
trimmed = dups.uniq |
This file contains hidden or 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
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 |
This file contains hidden or 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
lines = File.new('foo.txt', 'r').select do |line| | |
line =~ /pattern/ | |
end |
This file contains hidden or 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
lines = File.new('foo.txt', 'r').collect() do |line| | |
line.strip() | |
end |
This file contains hidden or 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
File.new('foo.txt', 'r').each() do |line| | |
# Process the line | |
print line | |
end |
This file contains hidden or 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
File.new('foo.txt', 'r').each() do |line| | |
# Process the line | |
print line | |
end |
NewerOlder