code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Basic #2
num_array = [3, 5, 1, 2, 7, 9, 8, 13, 25, 32]
puts num_array.inject(:+)
puts num_array.reject{ |a| a < 10 }
puts num_array.find_all{ |a| a > 10 }
name_array = ["John", "KB", "Oliver", "Cory", "Matthew", "Christopher"]
puts name_array.shuffle()
puts name_arr... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Intermediate
monster1 = {:health => 500}
monster2 = {:health => 500}
for i in 1..5
puts "ROUND #{i}:"
attack_damage = rand(1..100)
puts "monster1 attacks monster2 with %d damage" % [attack_damage]
puts "monster2's health is now %d/500" % monster2[:health] -= at... | Ruby |
#!/usr/bin/ruby
# Foung Vang
# Ruby - Excercise 2
# just excercise
# String
x = "CodingDojo"
puts x.length # output: 10
puts x.class # output: String
puts x.upcase
puts x.downcase
puts x[2] # output: d
puts x.include?("dojo") # output: false because it's case sensitive
puts x.include?("dojo") # output: fa... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Advanced
class MathDojo
attr_reader :sum
def initialize()
@sum = 0
end
def add(*nums)
nums.flatten!
nums.each { |a| @sum += a }
self
end
def subtract(*nums)
nums.flatten!
nums.each { |a| @sum -= a }
self
end
end
puts calculate = MathDojo.new... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Basic #2
num_array = [3, 5, 1, 2, 7, 9, 8, 13, 25, 32]
puts num_array.inject(:+)
puts num_array.reject{ |a| a < 10 }
puts num_array.find_all{ |a| a > 10 }
name_array = ["John", "KB", "Oliver", "Cory", "Matthew", "Christopher"]
puts name_array.shuffle()
puts name_arr... | Ruby |
#!/usr/bin/ruby
# Foung Vang
puts "Enter the first number"
first_number = gets.chomp
puts "Enter the second number"
second_number = gets.chomp
# random choose a # between 1 and 4
operation = rand(1..4)
operation = 1
# if version
puts "if version...\n"
if (operation == 1)
answer = first_number.to_i + second_number... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Basic #3
a = {:first_name => "Michael", :last_name => "Choi"}
b = {:first_name => "John", :last_name => "Supsupin"}
c = {:first_name => "KB", :last_name => "Tonel"}
d = {:first_name => "Mikee", :last_name => "Buyco"}
e = {:first_name => "Diana", :last_name => "Manlulu... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Basic #3
a = {:first_name => "Michael", :last_name => "Choi"}
b = {:first_name => "John", :last_name => "Supsupin"}
c = {:first_name => "KB", :last_name => "Tonel"}
d = {:first_name => "Mikee", :last_name => "Buyco"}
e = {:first_name => "Diana", :last_name => "Manlulu... | Ruby |
#!/usr/bin/ruby
# Foung Vang
puts "Enter the first number"
first_number = gets.chomp
puts "Enter the second number"
second_number = gets.chomp
# random choose a # between 1 and 4
operation = rand(1..4)
operation = 1
# if version
puts "if version...\n"
if (operation == 1)
answer = first_number.to_i + second_number... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Advanced
class MathDojo
attr_reader :sum
def initialize()
@sum = 0
end
def add(*nums)
nums.flatten!
nums.each { |a| @sum += a }
self
end
def subtract(*nums)
nums.flatten!
nums.each { |a| @sum -= a }
self
end
end
puts calculate = MathDojo.new... | Ruby |
#!/usr/bin/ruby
# Author: Foung Vang
# Assignment: Intermediate
monster1 = {:health => 500}
monster2 = {:health => 500}
for i in 1..5
puts "ROUND #{i}:"
attack_damage = rand(1..100)
puts "monster1 attacks monster2 with %d damage" % [attack_damage]
puts "monster2's health is now %d/500" % monster2[:health] -= at... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... | Ruby |
# Configure Spree Preferences
#
# Note: Initializing preferences available within the Admin will overwrite any changes that were made through the user interface when you restart.
# If you would like users to be able to update a setting with the Admin it should NOT be set here.
#
# In order to initialize a settin... | Ruby |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
Brands4less::Application.config.session_store :cookie_store, key: '_brands4less_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with ... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
Brands4less::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.ac... | Ruby |
Brands4less::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the we... | Ruby |
Brands4less::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the tes... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Brands4less::Application.initialize!
ActiveRecord::Base.include_root_in_json = true
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... | Ruby |
Brands4less::Application.routes.draw do
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the :at option to something different.
... | Ruby |
module ApplicationHelper
end
| Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
Deface::Override.new(:virtual_path => "spree/home/index",
:insert_top => "[data-hook='homepage_products']",
:text => "<%=image_tag 'home_banner.png'%>",
:name => "home_banner")
| Ruby |
Deface::Override.new(:virtual_path => "spree/products/show",
:insert_top => "[data-hook='product_show']",
:text => "<%=image_tag 'product_banner.png'%>",
:name => "product_banner")
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Brands4less::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'... | Ruby |
# This migration comes from spree (originally 20100223183812)
class DropBillingIntegrations < ActiveRecord::Migration
def up
drop_table :billing_integrations
end
def down
create_table :billing_integrations do |t|
t.string :type, :name
t.text :description
t.boolean :active, :default => t... | Ruby |
# This migration comes from spree (originally 20111219205902)
class AddDefaultTaxZone < ActiveRecord::Migration
def change
add_column :spree_zones, :default_tax, :boolean, :default => false
end
end
| Ruby |
# This migration comes from spree (originally 20100923162011)
class CreateMailMethods < ActiveRecord::Migration
def change
create_table :mail_methods do |t|
t.string :environment
t.boolean :active, :default => true
t.timestamps
end
end
end
| Ruby |
# This migration comes from spree (originally 20100317120946)
class AddAltTextToImages < ActiveRecord::Migration
def change
add_column :assets, :alt, :text
end
end
| Ruby |
# This migration comes from spree (originally 20100820135707)
class ResponseCodeAndAvsResponseForPayments < ActiveRecord::Migration
def change
add_column :payments, :response_code, :string
add_column :payments, :avs_response, :string
end
end
| Ruby |
# This migration comes from spree (originally 20101026184746)
class DeleteInProgressOrders < ActiveRecord::Migration
def up
execute("DELETE FROM orders WHERE orders.state = 'in_progress'")
delete_orphans('adjustments')
delete_orphans('checkouts')
delete_orphans('shipments')
delete_orphans('payment... | Ruby |
# This migration comes from spree (originally 20101117031806)
class FixProblematicIndexNames < ActiveRecord::Migration
def up
begin
remove_index :preferences, :name => 'index_preferences_on_owner_and_attribute_and_preference'
rescue ArgumentError
# ignore - already remove then
end
add_inde... | Ruby |
# This migration comes from spree_promo (originally 20110404123358)
class CreatePromotionActions < ActiveRecord::Migration
def change
create_table :promotion_actions do |t|
t.integer :activator_id
t.integer :position
t.string :type
end
end
end
| Ruby |
# This migration comes from spree (originally 20091017175558)
class CreateBillingIntegrations < ActiveRecord::Migration
def change
create_table :billing_integrations do |t|
t.string :type, :name
t.text :description
t.boolean :active, :default => true
t.string :environment, :default => 'dev... | Ruby |
# This migration comes from spree (originally 20091015110842)
class AddOpenIdAuthenticationTables < ActiveRecord::Migration
def change
create_table :open_id_authentication_associations, :force => true do |t|
t.integer :issued, :lifetime
t.string :handle, :assoc_type
t.binary :server_url, :s... | Ruby |
# This migration comes from spree (originally 20100209144531)
# Legacy table support
class Checkout < ActiveRecord::Base; end;
class PolymorphicPayments < ActiveRecord::Migration
def up
remove_column :payments, :type
remove_column :payments, :creditcard_id
rename_column :payments, :order_id, :payable_id
... | Ruby |
# This migration comes from spree (originally 20101008190536)
class MoveSpecialInstructionsToOrders < ActiveRecord::Migration
def up
add_column :orders, :special_instructions, :text
execute "UPDATE orders SET special_instructions = (SELECT special_instructions FROM checkouts WHERE order_id = orders.id)"
end... | Ruby |
# This migration comes from spree (originally 20110111122537)
class AddPositionToOptionTypes < ActiveRecord::Migration
def change
add_column :option_types, :position, :integer, :null => false, :default => 0
end
end
| Ruby |
# This migration comes from spree_auth (originally 20101214150824)
class ConvertUserRememberField < ActiveRecord::Migration
def up
remove_column :spree_users, :remember_created_at
add_column :spree_users, :remember_created_at, :datetime
end
def down
remove_column :spree_users, :remember_created_at
... | Ruby |
# This migration comes from spree (originally 20100113090919)
class AddReturnAuthorizationToInventoryUnits < ActiveRecord::Migration
def change
add_column :inventory_units, :return_authorization_id, :integer
end
end
| Ruby |
# This migration comes from spree (originally 20100811205836)
class DropOrderToken < ActiveRecord::Migration
def up
remove_column :orders, :token
end
def down
add_column :orders, :token, :string
end
end
| Ruby |
# This migration comes from spree (originally 20100504142133)
class AddAddressesCheckoutsIndexes < ActiveRecord::Migration
def change
add_index :addresses, :firstname
add_index :addresses, :lastname
add_index :checkouts, :order_id
add_index :checkouts, :bill_address_id
end
end
| Ruby |
# This migration comes from spree_promo (originally 20110331094351)
class PromotionChangesToSubclassOfActivator < ActiveRecord::Migration
def up
drop_table :promotions
rename_column :promotion_rules, :promotion_id, :activator_id
end
def down
create_table :promotions, :force => true do |t|
t.str... | Ruby |
# This migration comes from spree_promo (originally 20100923095305)
class UpdateCalculableTypeForPromotions < ActiveRecord::Migration
def up
execute "UPDATE spree_calculators SET calculable_type = 'Promotion' WHERE calculable_type = 'Coupon'"
end
def down
execute "UPDATE spree_calculators SET calculable_... | Ruby |
# This migration comes from spree (originally 20101026184700)
class CreateLogEntries < ActiveRecord::Migration
def change
create_table :log_entries do |t|
t.integer :source_id
t.string :source_type
t.text :details
t.timestamps
end
end
end
| Ruby |
# This migration comes from spree (originally 20101103212716)
class DropAnonymousFieldForUser < ActiveRecord::Migration
def up
unless defined?(User)
remove_column :users, :anonymous
end
end
def down
add_column :users, :anonymous, :boolean
end
end
| Ruby |
# This migration comes from spree (originally 20110110130847)
class AddNextStateToStateEvents < ActiveRecord::Migration
def change
add_column :state_events, :next_state, :string
end
end
| Ruby |
# This migration comes from spree (originally 20100105132138)
class ShipmentIdForInventoryUnits < ActiveRecord::Migration
def up
add_column :inventory_units, :shipment_id, :integer
add_index :inventory_units, :shipment_id
# migrate legacy shipments
Spree::Shipment.table_name = 'shipments'
Spree:... | Ruby |
# This migration comes from spree (originally 20100624175547)
class RenamePreferencesField < ActiveRecord::Migration
def change
rename_column :preferences, :attribute, :name
end
end
| Ruby |
# This migration comes from spree (originally 20100214212536)
class AssignCreditcardTxnsToPayment < ActiveRecord::Migration
def up
add_column :creditcard_txns, :payment_id, :integer
# Temporarily set back to creditcards
Spree::CreditCard.table_name = 'creditcards'
ActiveRecord::Base.connection.selec... | Ruby |
# This migration comes from spree (originally 20120105193911)
class AssociateShippingMethodsAndShippingCategories < ActiveRecord::Migration
def change
change_table :spree_shipping_methods do |t|
t.references :shipping_category
end
end
end
| Ruby |
# This migration comes from spree (originally 20120523061241)
class ConvertSalesTaxToDefaultTax < ActiveRecord::Migration
def up
execute "UPDATE spree_calculators SET type='Spree::Calculator::DefaultTax' WHERE type='Spree::Calculator::SalesTax'"
end
def down
execute "UPDATE spree_calculators SET type='Sp... | Ruby |
# This migration comes from spree (originally 20100223170312)
class StiForTransactions < ActiveRecord::Migration
def up
rename_table :creditcard_txns, :transactions
add_column :transactions, :type, :string
remove_column :transactions, :creditcard_id
execute "UPDATE transactions SET type = 'Credit... | Ruby |
# This migration comes from spree_promo (originally 20100419190933)
class RenameCouponsToPromotions < ActiveRecord::Migration
def up
drop_table :promotions if table_exists?(:promotions)
rename_table :coupons, :promotions
end
def down
rename_table :promotions, :coupons
end
end
| Ruby |
# This migration comes from spree (originally 20090923100315)
class AddCountOnHandToVariantsAndProducts < ActiveRecord::Migration
def up
add_column :variants, :count_on_hand, :integer, :default => 0, :null => false
add_column :products, :count_on_hand, :integer, :default => 0, :null => false
# Due to our... | Ruby |
# This migration comes from spree (originally 20120416233427)
class RenameAttachmentSizeToAttachmentFileSize < ActiveRecord::Migration
def change
rename_column :spree_assets, :attachment_size, :attachment_file_size
end
end
| Ruby |
# This migration comes from spree (originally 20120509055454)
class CreateTokenizedPermissionsTable < ActiveRecord::Migration
def change
unless Spree::TokenizedPermission.table_exists?
create_table :spree_tokenized_permissions do |t|
t.integer :permissable_id
t.string :permissable_type
... | Ruby |
# This migration comes from spree_social (originally 20120123163222)
class CreateAuthenticationMethods < ActiveRecord::Migration
def change
create_table :spree_authentication_methods do |t|
t.string :environment
t.string :provider
t.string :api_key
t.string :api_secret
t.boolean :act... | Ruby |
# This migration comes from spree (originally 20101223215658)
class AddPositionToVariants < ActiveRecord::Migration
def change
add_column :variants, :position, :integer
end
end
| Ruby |
# This migration comes from spree (originally 20111007143030)
class NamespaceTopLevelModels < ActiveRecord::Migration
def change
rename_table :activators, :spree_activators
rename_table :addresses, :spree_addresses
rename_table :adjustments, :spree_adjustments
re... | Ruby |
# This migration comes from spree (originally 20101026192225)
class CleanupLegacyTables < ActiveRecord::Migration
def up
drop_table :checkouts
drop_table :transactions
drop_table :open_id_authentication_associations
drop_table :open_id_authentication_nonces
end
def down
end
end
| Ruby |
# This migration comes from spree_api (originally 20120411123334)
class ResizeApiKeyField < ActiveRecord::Migration
def change
unless defined?(User)
change_column :spree_users, :api_key, :string, :limit => 48
end
end
end
| Ruby |
# This migration comes from spree_social (originally 20120120163432)
class CreateUserAuthentications < ActiveRecord::Migration
def change
create_table :spree_user_authentications do |t|
t.integer :user_id
t.string :provider
t.string :uid
t.timestamps
end
end
end
| Ruby |
# This migration comes from spree (originally 20091021133257)
class Checkout < ActiveRecord::Base; end;
# Hack to prevent issues with legacy migrations
class Order < ActiveRecord::Base
has_one :checkout
end
class ChargeRefactoring < ActiveRecord::Migration
def up
# Temporarily set table name for legacy suppor... | Ruby |
# This migration comes from spree (originally 20111216154844)
class AddIncTaxToTaxRates < ActiveRecord::Migration
def change
add_column :spree_tax_rates, :inc_tax, :boolean, :default => false
end
end
| Ruby |
# This migration comes from spree (originally 20120712172620)
class AddCounterCacheToZoneMembers < ActiveRecord::Migration
def up
add_column :spree_zones, :zone_members_count, :integer, :default => 0
Spree::Zone.reset_column_information
Spree::Zone.find(:all).each do |zone|
Spree::Zone.update_count... | Ruby |
# This migration comes from spree_promo (originally 20110601202923)
class CreatePromotionActionLineItems < ActiveRecord::Migration
def change
create_table :promotion_action_line_items do |t|
t.integer :promotion_action_id, :variant_id
t.integer :quantity, :default => 1
t.references :promotion_ac... | Ruby |
# This migration comes from spree_skrill (originally 20111118164631)
class CreateSkrillTransactions < ActiveRecord::Migration
def change
create_table :spree_skrill_transactions do |t|
t.string :email
t.float :amount
t.string :currency
t.integer :transaction_id
t.integer :customer_id
... | Ruby |
# This migration comes from spree (originally 20091126190904)
class CheckoutStateMachine < ActiveRecord::Migration
def change
add_column :checkouts, :state, :string
end
end
| Ruby |
# This migration comes from spree (originally 20101111133551)
class RenamedRmaCancelledState < ActiveRecord::Migration
def up
execute "UPDATE return_authorizations SET state = 'canceled' WHERE state = 'cancelled'"
end
def down
execute "UPDATE return_authorizations SET state = 'cancelled' WHERE state = 'c... | Ruby |
# This migration comes from spree_promo (originally 20100501095202)
class CreatePromotionRulesUsers < ActiveRecord::Migration
def up
create_table :promotion_rules_users do |t|
t.integer :user_id, :promotion_rule_id
end
remove_column :promotion_rules_users, :id
add_index :promotion_rules_users, :... | Ruby |
# This migration comes from spree (originally 20110329141434)
class CreateActivators < ActiveRecord::Migration
def change
create_table :activators, :force => true do |t|
t.string :description
t.datetime :expires_at
t.datetime :created_at
t.datetime :updated_at
t.datetime :starts_at... | Ruby |
# This migration comes from spree (originally 20100301163454)
class AddAdjustmentsIndex < ActiveRecord::Migration
def change
add_index :adjustments, :order_id
end
end
| Ruby |
# This migration comes from spree_promo (originally 20100426100726)
class CreatePromotionRules < ActiveRecord::Migration
def up
create_table :promotion_rules do |t|
t.references :promotion, :user, :product_group
t.string :type
t.timestamps
end
add_index :promotion_rules, :product_group_... | Ruby |
# This migration comes from spree (originally 20100624110730)
class AddDisplayToShippingMethods < ActiveRecord::Migration
def change
add_column :shipping_methods, :display_on, :string, :default => nil
end
end
| Ruby |
# This migration comes from spree (originally 20101026184932)
class PreventNilEmail < ActiveRecord::Migration
def up
execute "UPDATE orders SET email = 'guest@example.com' WHERE email IS NULL"
execute "UPDATE orders SET email = 'guest@example.com' WHERE email = ''"
end
def down
end
end
| Ruby |
# This migration comes from spree_auth (originally 20101026184950)
class RenameColumnsForDevise < ActiveRecord::Migration
def up
return if column_exists?(:spree_users, :password_salt)
rename_column :spree_users, :crypted_password, :encrypted_password
rename_column :spree_users, :salt, :password_salt
r... | Ruby |
# This migration comes from spree (originally 20091214183826)
class PopulateLegacyShipmentState < ActiveRecord::Migration
def up
shipments = select_all "SELECT * FROM shipments"
shipments.each do |shipment|
if shipment['shipped_at']
execute "UPDATE shipments SET state = 'shipped'"
else
... | Ruby |
# This migration comes from spree (originally 20111201024007)
class MakeAdjustmentsPolymorphic < ActiveRecord::Migration
def change
add_column :spree_adjustments, :adjustable_type, :string
rename_column :spree_adjustments, :order_id, :adjustable_id
execute "UPDATE spree_adjustments SET adjustable_type = ... | Ruby |
# This migration comes from spree (originally 20100121183934)
class OriginalCreditcardTxnIdForCreditcardTxns < ActiveRecord::Migration
def change
add_column :creditcard_txns, :original_creditcard_txn_id, :integer
end
end
| Ruby |
# This migration comes from spree (originally 20120119024710)
require 'spree/core/preference_rescue'
class NewPreferences < ActiveRecord::Migration
def up
add_column :spree_preferences, :key, :string
add_column :spree_preferences, :value_type, :string
add_index :spree_preferences, :key, :unique => true
... | Ruby |
# This migration comes from spree (originally 20090904192342)
class CreateIndexesForInventoryUnits < ActiveRecord::Migration
def change
add_index :inventory_units, :variant_id
add_index :inventory_units, :order_id
end
end
| Ruby |
# This migration comes from spree (originally 20101026185022)
class UpdateOrderState < ActiveRecord::Migration
def up
Spree::Order.table_name = 'orders'
Spree::Order.all.map(&:update!)
Spree::Order.table_name = 'spree_orders'
end
def down
end
end
| Ruby |
# This migration comes from spree (originally 20100813023502)
class CreateAddressKeysForOrder < ActiveRecord::Migration
def change
add_column :orders, :bill_address_id, :integer
add_column :orders, :ship_address_id, :integer
end
end | Ruby |
# This migration comes from spree (originally 20091007134354)
class ChangeTaxonsToNestedSet < ActiveRecord::Migration
def up
add_column :taxons, :lft, :integer
add_column :taxons, :rgt, :integer
Spree::Taxon.reset_column_information # So the new root ids get saved
# Temporarily set the table back to... | Ruby |
# This migration comes from spree_auth (originally 20120203010234)
class AddResetPasswordSentAtToSpreeUsers < ActiveRecord::Migration
def change
Spree::User.reset_column_information
unless Spree::User.column_names.include?("reset_password_sent_at")
add_column :spree_users, :reset_password_sent_at, :date... | Ruby |
# This migration comes from spree (originally 20100528155333)
class IndexForShipmentsNumber < ActiveRecord::Migration
def change
add_index :shipments, :number
end
end
| Ruby |
# This migration comes from spree (originally 20100813185745)
class PaymentTotalForOrders < ActiveRecord::Migration
def change
add_column :orders, :payment_total, :decimal, :precision => 8, :scale => 2, :default => 0.0
end
end
| Ruby |
# This migration comes from spree_promo (originally 20100502163939)
class NameForPromotions < ActiveRecord::Migration
def change
add_column :promotions, :name, :string
end
end
| Ruby |
# This migration comes from spree (originally 20091212161118)
class ShippingMethodIdForCheckouts < ActiveRecord::Migration
def change
add_column :checkouts, :shipping_method_id, :integer
end
end
| Ruby |
# This migration comes from spree (originally 20100224153127)
class DeletedAtForPaymentMethods < ActiveRecord::Migration
def up
change_table :payment_methods do |t|
t.timestamp :deleted_at, :default => nil
end
end
def down
remove_column :payments_methods, :column_name
change_table :payment_... | Ruby |
# This migration comes from spree (originally 20111107143030)
class MigrateNamespacedPolymorphicModels < ActiveRecord::Migration
def concat(str1, str2)
dbtype = Rails.configuration.database_configuration[Rails.env]['adapter'].to_sym
case dbtype
when :mysql, :mysql2
"CONCAT(#{str1}, #{str2})"
wh... | Ruby |
# This migration comes from spree (originally 20091016174634)
class ChangePreferenceValueType < ActiveRecord::Migration
def up
remove_index :preferences, :name => 'index_preferences_on_owner_and_attribute_and_preference'
change_column :preferences, :value, :text
end
def down
change_column :preference... | Ruby |
# This migration comes from spree (originally 20100419194457)
class Adjustment < ActiveRecord::Base; end;
class FixExistingCouponCredits < ActiveRecord::Migration
def up
execute("UPDATE adjustments SET type='PromotionCredit' WHERE type='CouponCredit'")
execute("UPDATE adjustments SET adjustment_source_type='... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.