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
courses.each do |course| | |
InventoryLineItem.where(course_id: course.id).update_all master_variants[course.id] | |
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
Shirt: | |
Color: Red, Blue, Yellow | |
Pants: | |
Color: Red, Blue, Yellow | |
Clothes Bundle: | |
Color: Red, Blue, Yellow. |
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 Spree::Variant | |
def course_with_fallback | |
course || product.course | |
end | |
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
module ApplicationHelper | |
def edit_create_info_link(model) | |
model_name = model.class.to_s.underscore | |
if model.persisted? | |
link_to 'Edit', { :action => "#{model_name}_info_edit", :id => barn.url, :search_name => params[:search_name], :page => params[:page] }, id: "#{model.url}-info-edit" | |
else | |
link_to 'Create', { :action => "new_#{model_name}_info", :id => barn.url, :search_name => params[:search_name], :page => params[:page] }, id: "#{model.url}-info-create" | |
end | |
end | |
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
class Login | |
has_one :user | |
end | |
class User | |
belongs_to :login | |
delegate :first_name, :first_name=, to: :login | |
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
class Product | |
belongs_to :course | |
end | |
class Variant | |
belongs_to :course | |
end | |
class InventoryOrder | |
def process |
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 task_with_lock(*args) | |
lock | |
task(args) | |
unlock | |
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
class Subscription | |
def upgrade_to(plan, options={}) | |
update_attributes(subscription_plan: plan, | |
minimum_user_amount: options.delete(:users_count)) | |
end | |
def has_addons? | |
addons_count > 0 | |
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
module Spree | |
class LineItem < ActiveRecord::Base | |
has_many :adjustments, as: :adjustable, dependent: :destroy, reject_if: -> { |a| a.amount == 0 } | |
end | |
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
class Model | |
def abc | |
return 0 | |
end | |
def xyz | |
return 1 | |
end | |
end |