Starting Import of Artists… 1335.900000 83.280000 1419.180000 (2532.872472) Finished importing Artists with 518928 new records. 0 old or failed attempts It took approximately -42.2145436333333 minutes
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
#/usr/bin/ruby | |
require 'rubygems' | |
require 'activerecord' | |
ActiveRecord::Base.establish_connection( | |
:adapter => "mysql", | |
:host => "localhost", | |
:username => "root", | |
:password => "", | |
:database => "lame" |
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
class ApplicationController < ActionController::Base | |
before_filter :update_session_expiration_date | |
private | |
def update_session_expiration_date | |
options = ActionController::Base.session_options | |
unless options[:session_expires] | |
options[:session_expires] = 1.year.from_now | |
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
@implementation ResortVenueViewController | |
@synthesize venue, venueID, managedObjectContext, locationOrPhotos; | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; | |
NSEntityDescription *entity = | |
[NSEntityDescription entityForName:@"Venue" |
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
development: | |
access_key_id: XXXXXXXXXXX | |
secret_access_key: XXXXXXXXXXX | |
bucket: alexrbarlow-dev | |
cloudfront_cname: xxxxxxx.cloudfront.net #Optional, without, s3 is used. |
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
has_attached_file :image, | |
:storage => :s3, | |
:s3_credentials => "#{Rails.root.to_s}/config/aws.yml", | |
:path => "images/:id/:style:unix_time.:extension" |
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
class Release < ActiveRecord::Base | |
has_many :songs | |
end | |
# Tell Rails, update a "songs_count" field on the parent record after creation/deletion | |
class Song < ActiveRecord::Base | |
belongs_to :release, :counter_cache => true | |
end | |
r = Release.first |
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
class Release < ActiveRecord::Base | |
has_many :songs, :dependent => :destroy | |
end | |
# Any song belonging to the Release deleted, will also be deleted |
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
class Order < ActiveRecord::Base | |
has_many :order_products | |
validates_associated :order_products # This checks all the order_product instances are valid | |
end | |
class OrderProduct < ActiveRecord::Base | |
belongs_to :order | |
belongs_to :product | |
validates :order, :product, :presence => true | |
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
# This is the wrong was to do this. What if one of the order products fails? | |
def create | |
@order = Order.new | |
if @order.save | |
for order in params[:order][:product_ids] | |
OrderProducts.create(:order_id => @order.id, :product_id => Product.find(params[:id]).id) | |
end | |
flash[:notice] = "Thanks, your order will be completed shortly!" | |
redirect_to :action => "index" | |
else |
OlderNewer