This file contains 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
puts "Loading regular seeds" | |
Dir[Rails.root.join("db/seed", "*.{yml,csv}")].each do |file| | |
Fixtures.create_fixtures("db/seed", File.basename(file, '.*')) | |
end |
This file contains 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 'active_record/fixtures' | |
puts "Loading regular seeds" | |
Dir[Rails.root.join("db/seed", "*.{yml,csv}")].each do |file| | |
Fixtures.create_fixtures("db/seed", File.basename(file, '.*')) | |
end | |
puts "Loading #{Rails.env} seeds" | |
Dir[Rails.root.join("db/seed", Rails.env, "*.{yml,csv}")].each do |file| | |
Fixtures.create_fixtures("db/seed/#{Rails.env}", File.basename(file, '.*')) |
This file contains 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
### USAGE ### | |
# MODEL=User FILE="db/seed/development/user.csv" rake export_model | |
task :export_model => :environment do | |
MODEL = ENV["MODEL"].constantize | |
FILE = ENV["FILE"] | |
objects = MODEL.find(:all) | |
FasterCSV.open(File.join(Rails.root, FILE), "w") do |csv| | |
csv << MODEL.column_names |
This file contains 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 'faker' | |
500.times do | |
User.create(:email => Faker::Internet.email, :name => Faker::Name.name, :password => "passw0rd", :age => (rand(60) + 1) | |
end |
This file contains 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
def long_method | |
@running = true | |
begin | |
really_long_code | |
ensure | |
@running = false | |
end | |
end | |
long_method # => NameError: undefined local variable or method `really_long_code' for #<Object:0x102310508> |
This file contains 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
<h1>Listing businesses</h1> | |
<%= add_map("map_div", @businesses, {:labels => true}) %> | |
<div id="map_div" style="width: 600px; height: 400px;"></div> | |
<table> | |
<tr> | |
<th>Address</th> | |
<th>Latitude</th> | |
<th>Longitude</th> | |
</tr> |
This file contains 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
$ time ruby script/runner | |
Run 'script/runner -h' for help. | |
real 0m22.632s | |
user 0m7.468s | |
sys 0m1.933s | |
Rails v2.3.5 loaded via vendor/rails |
This file contains 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
def index | |
@query = params[:query] | |
@page = params.fetch(:page, 1) | |
if @query.nil? | |
@wines = Wine.paginate(:page => @page, :per_page => 9) | |
logger.info("Doing index, not search") | |
else | |
@search = Wine.search do | |
keywords(@query) | |
end |
This file contains 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
$(document).ready(function(){ | |
$('a.remove-participant').live('click', function(){ | |
console.log("Clicked remove"); | |
$(this).parent('.participant').hide(); | |
$(this).siblings('.destroy_participant').find('input[type="hidden"]').val(1); | |
return false; | |
}); | |
}); |
This file contains 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
# Required so that we can set path correctly for Config, which | |
# is loaded statically due to a bug in cijoe | |
require 'cijoe' | |
# setup middleware | |
use Rack::CommonLogger | |
# Assume all subfolders under config.ru are git repos and collect them to spin up multiple joes | |
projects = Dir.glob("*/") |