Permalink
Browse files

Rails bump to 4.1

  • Loading branch information...
stephskardal committed Apr 7, 2014
1 parent ef4a33b commit 9174688a0f96cedb1b8707b54898a8b5fdbb9393
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
piggybak (0.7.0)
piggybak (0.7.1)
activemerchant
countries
rack-ssl-enforcer
View
@@ -11,7 +11,7 @@ Modular / mountable ecommerce gem. Features:
* Fully defined backend RailsAdmin interface for adding orders on the backend
* Piggybak 0.7.0 is compatible with Rails 4, and earlier versions compatible with Rails 3.
* Piggybak 0.7.1 is compatible with Rails 4.1, 0.7.0 is compatible with Rails 4, and earlier version compatible with Rails 3.
Announcements
View
@@ -1,3 +1,7 @@
0.7.1
Released: 4.07.2014
* Upgrade to Rails 4.1
0.7.0
Released: 03.31.2014
* Initial release for Rails 4 upgrade
@@ -74,15 +74,15 @@ def receipt
return
end
@order = Piggybak::Order.find(session[:last_order])
@order = Piggybak::Order.where(id: session[:last_order]).first
end
def list
redirect_to root_url if current_user.nil?
end
def download
@order = Piggybak::Order.find(params[:id])
@order = Piggybak::Order.where(id: params[:id]).first
if can?(:download, @order)
render :layout => false
@@ -92,7 +92,7 @@ def download
end
def email
order = Piggybak::Order.find(params[:id])
order = Piggybak::Order.where(id: params[:id]).first
if can?(:email, order)
Piggybak::Notifier.order_notification(order).deliver
@@ -104,7 +104,7 @@ def email
end
def cancel
order = Piggybak::Order.find(params[:id])
order = Piggybak::Order.where(id: params[:id]).first
if can?(:cancel, order)
order.recorded_changer = current_user.id
@@ -19,7 +19,7 @@ class Address < ActiveRecord::Base
attr_accessor :is_shipping
def set_default_country
self.country ||= Country.find_by_abbr(Piggybak.config.default_country)
self.country ||= Country.where(abbr: Piggybak.config.default_country).first
end
def admin_label
@@ -12,7 +12,7 @@ def initialize(cookie='')
self.errors = []
cookie ||= ''
cookie.split(';').each do |item|
item_sellable = Piggybak::Sellable.find_by_id(item.split(':')[0])
item_sellable = Piggybak::Sellable.where(id: item.split(':')[0]).first
if item_sellable.present?
self.sellables << { :sellable => item_sellable, :quantity => (item.split(':')[1]).to_i }
end
@@ -9,7 +9,7 @@ class LineItem < ActiveRecord::Base
validates :quantity, presence: true
validates_numericality_of :quantity, :only_integer => true, :greater_than_or_equal_to => 0
default_scope :order => 'created_at ASC'
default_scope { order('created_at ASC') }
after_create :decrease_inventory, :if => Proc.new { |line_item| line_item.line_item_type == 'sellable' && !line_item.sellable.unlimited_inventory }
after_destroy :increase_inventory, :if => Proc.new { |line_item| line_item.line_item_type == 'sellable' && !line_item.sellable.unlimited_inventory }
@@ -46,7 +46,7 @@ def preprocess_sellable
return
end
sellable = Piggybak::Sellable.find(self.sellable_id)
sellable = Piggybak::Sellable.where(id: self.sellable_id).first
return if sellable.nil?
@@ -85,7 +85,7 @@ def preprocess_shipment
def preprocess_payment
if self.new_record?
self.build_payment if self.payment.nil?
self.payment.payment_method_id ||= Piggybak::PaymentMethod.find_by_active(true).id
self.payment.payment_method_id ||= Piggybak::PaymentMethod.where(active: true).first.id
self.description = "Payment"
self.price = 0
end
@@ -140,7 +140,7 @@ def increase_inventory
def update_inventory
if self.sellable_id != self.sellable_id_was
old_sellable = Sellable.find(self.sellable_id_was)
old_sellable = Sellable.where(id: self.sellable_id_was).first
old_sellable.update_inventory(self.quantity_was)
self.sellable.update_inventory(-1*self.quantity)
else
@@ -30,7 +30,7 @@ class Order < ActiveRecord::Base
after_save :record_order_note
after_save :deliver_order_confirmation, :if => Proc.new { |order| !order.confirmation_sent }
default_scope :order => 'created_at DESC'
default_scope { order('created_at ASC') }
def deliver_order_confirmation
Piggybak::Notifier.order_notification(self).deliver
@@ -5,7 +5,7 @@ class OrderNote < ActiveRecord::Base
belongs_to :order
belongs_to :user
default_scope :order => 'created_at ASC'
default_scope { order('created_at ASC') }
def details
"<b>#{created_at.strftime("%m-%d-%Y %H:%M")}</b> by #{user ? user.email : 'N/A'}:<br />#{note}"
@@ -26,7 +26,7 @@ def klass_enum
end
end
validates_each :active do |record, attr, value|
if value && PaymentMethod.find_all_by_active(true).select { |p| p != record }.size > 0
if value && PaymentMethod.where(active: true).select { |p| p != record }.size > 0
record.errors.add attr, "You may only have one active payment method."
end
end
@@ -27,13 +27,13 @@ def klass_enum
end
def self.available_methods(cart)
active_methods = ShippingMethod.find_all_by_active(true)
active_methods = ShippingMethod.where(active: true)
active_methods.select { |method| method.klass.constantize.available?(method, cart) }
end
def self.lookup_methods(cart)
active_methods = ShippingMethod.find_all_by_active(true)
active_methods = ShippingMethod.where(active: true)
methods = active_methods.inject([]) do |arr, method|
klass = method.klass.constantize
@@ -6,7 +6,7 @@ def self.available?(method, object)
id = method.metadata.detect { |t| t.key == "state_id" }.value
if object.is_a?(Cart) && object.extra_data.has_key?(:state_id) && object.extra_data[:state_id] != ''
state = State.find(object.extra_data[:state_id])
state = State.where(id: object.extra_data[:state_id]).first
return state.id == id.to_i if state
elsif object.is_a?(Order) && object.billing_address && object.billing_address.state
return object.billing_address.state.id == id.to_i
View
@@ -1,3 +1,3 @@
module Piggybak
VERSION = "0.7.0"
VERSION = "0.7.1"
end

0 comments on commit 9174688

Please sign in to comment.