forge-cli 0.0.18 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +106 -0
  3. data/bin/cucumber +16 -0
  4. data/bin/erubis +16 -0
  5. data/bin/htmldiff +16 -0
  6. data/bin/ldiff +16 -0
  7. data/bin/rackup +16 -0
  8. data/bin/rake +16 -0
  9. data/bin/rdoc +16 -0
  10. data/bin/ri +16 -0
  11. data/bin/sprockets +16 -0
  12. data/bin/thor +16 -0
  13. data/bin/tilt +16 -0
  14. data/bin/tt +16 -0
  15. data/lib/forge-cli.rb +1 -0
  16. data/lib/forge-cli/application_creator.rb +25 -6
  17. data/lib/forge-cli/controller_module_includer.rb +43 -0
  18. data/lib/forge-cli/module_installer.rb +18 -13
  19. data/lib/forge-cli/modules/banners/routes.rb +1 -1
  20. data/lib/forge-cli/modules/base/forge_routes.rb +4 -4
  21. data/lib/forge-cli/modules/base/manifest.yml +9 -4
  22. data/lib/forge-cli/modules/base/post_hooks.rb +9 -2
  23. data/lib/forge-cli/modules/base/routes.rb +4 -4
  24. data/lib/forge-cli/modules/dispatches/forge_routes.rb +2 -2
  25. data/lib/forge-cli/modules/dispatches/manifest.yml +2 -1
  26. data/lib/forge-cli/modules/ecommerce/manifest.yml +5 -1
  27. data/lib/forge-cli/modules/ecommerce/post_hooks.rb +13 -21
  28. data/lib/forge-cli/modules/events/routes.rb +1 -1
  29. data/lib/forge-cli/modules/posts/manifest.yml +4 -1
  30. data/lib/forge-cli/modules/posts/post_hooks.rb +9 -17
  31. data/lib/forge-cli/modules/posts/routes.rb +1 -1
  32. data/lib/forge-cli/modules/videos/routes.rb +1 -1
  33. data/lib/forge-cli/version.rb +2 -2
  34. data/lib/forge/Gemfile +3 -9
  35. data/lib/forge/Gemfile.lock +214 -210
  36. data/lib/forge/app/controllers/forge/help_topics_controller.rb +2 -2
  37. data/lib/forge/app/controllers/forge/posts_controller.rb +1 -0
  38. data/lib/forge/app/controllers/forge/products_controller.rb +0 -4
  39. data/lib/forge/app/controllers/forge/users_controller.rb +0 -1
  40. data/lib/forge/app/controllers/forge_controller.rb +7 -6
  41. data/lib/forge/app/controllers/posts_controller.rb +0 -2
  42. data/lib/forge/app/controllers/sessions_controller.rb +2 -3
  43. data/lib/forge/app/helpers/forge_helper.rb +2 -2
  44. data/lib/forge/app/models/address.rb +3 -0
  45. data/lib/forge/app/models/asset.rb +9 -10
  46. data/lib/forge/app/models/banner.rb +3 -1
  47. data/lib/forge/app/models/comment.rb +17 -2
  48. data/lib/forge/app/models/comment_subscriber.rb +3 -0
  49. data/lib/forge/app/models/contact.rb +3 -0
  50. data/lib/forge/app/models/country.rb +5 -2
  51. data/lib/forge/app/models/dispatch.rb +5 -2
  52. data/lib/forge/app/models/dispatch_bounce.rb +3 -0
  53. data/lib/forge/app/models/dispatch_link.rb +4 -1
  54. data/lib/forge/app/models/dispatch_link_click.rb +4 -0
  55. data/lib/forge/app/models/dispatch_open.rb +5 -1
  56. data/lib/forge/app/models/dispatch_unsubscribe.rb +4 -0
  57. data/lib/forge/app/models/event.rb +3 -1
  58. data/lib/forge/app/models/gallery.rb +4 -1
  59. data/lib/forge/app/models/help_topic.rb +4 -1
  60. data/lib/forge/app/models/line_item.rb +2 -2
  61. data/lib/forge/app/models/order.rb +1 -1
  62. data/lib/forge/app/models/order_transaction.rb +3 -0
  63. data/lib/forge/app/models/page.rb +5 -5
  64. data/lib/forge/app/models/photo.rb +5 -1
  65. data/lib/forge/app/models/post.rb +3 -1
  66. data/lib/forge/app/models/post_category.rb +4 -0
  67. data/lib/forge/app/models/product.rb +4 -2
  68. data/lib/forge/app/models/product_category.rb +4 -1
  69. data/lib/forge/app/models/product_image.rb +4 -0
  70. data/lib/forge/app/models/province.rb +4 -1
  71. data/lib/forge/app/models/queued_dispatch.rb +7 -4
  72. data/lib/forge/app/models/role.rb +3 -0
  73. data/lib/forge/app/models/sale.rb +2 -0
  74. data/lib/forge/app/models/subscriber.rb +4 -0
  75. data/lib/forge/app/models/subscriber_group.rb +4 -0
  76. data/lib/forge/app/models/subscriber_group_member.rb +4 -0
  77. data/lib/forge/app/models/tax_rate.rb +5 -2
  78. data/lib/forge/app/models/user.rb +1 -2
  79. data/lib/forge/app/models/video.rb +2 -0
  80. data/lib/forge/app/models/video_feed.rb +2 -2
  81. data/lib/forge/app/views/forge/assets/_asset.html.haml +1 -1
  82. data/lib/forge/app/views/forge/posts/_post.html.haml +5 -2
  83. data/lib/forge/app/views/forge/settings/_ecommerce.html.haml +4 -0
  84. data/lib/forge/app/views/forge/subscribers/_subscriber.html.haml +2 -2
  85. data/lib/forge/app/views/user_mailer/approved.html.haml +1 -1
  86. data/lib/forge/config/application.rb +3 -9
  87. data/lib/forge/config/database.yml.template +30 -0
  88. data/lib/forge/config/environments/development.rb +3 -7
  89. data/lib/forge/config/environments/production.rb +6 -0
  90. data/lib/forge/config/environments/test.rb +5 -3
  91. data/lib/forge/config/initializers/ckeditor.rb +15 -143
  92. data/lib/forge/config/initializers/devise.rb +12 -2
  93. data/lib/forge/config/initializers/ecommerce.rb +1 -1
  94. data/lib/forge/config/initializers/secret_token.rb +1 -10
  95. data/lib/forge/config/routes.rb +7 -11
  96. data/lib/forge/config/settings.yml +82 -5
  97. data/lib/forge/config/sitemap.yml +3 -1
  98. data/lib/forge/db/migrate/20130405172031_create_products_tax_rates.rb +15 -0
  99. data/lib/forge/db/migrate/{20130405172040_create_subscribers copy.rb → 20130405172040_create_subscribers.rb} +0 -0
  100. data/lib/forge/db/seeds.rb +304 -298
  101. data/lib/forge/doc/update_to_rails4_notes.md +15 -0
  102. data/lib/forge/lib/assets/javascripts/forge/features/help.js.erb +5 -4
  103. data/lib/forge/lib/assets/javascripts/forge/forge_manifest.js.erb +2 -2
  104. data/lib/forge/lib/assets/stylesheets/forge/forge.ui.css.scss +4 -3
  105. data/lib/forge/lib/forge/can_use_asset.rb +5 -7
  106. data/lib/forge/lib/forge/config/ecommerce.rb +3 -3
  107. data/lib/forge/lib/forge/shared_controller_methods/ecommerce.rb +3 -3
  108. data/lib/forge/lib/generators/forge/scaffold/USAGE +1 -1
  109. data/lib/forge/lib/tasks/forge.rake +5 -10
  110. data/lib/forge/public/500.html +1 -0
  111. data/lib/forge/public/javascripts/ckeditor/config.js +0 -1
  112. metadata +39 -39
  113. data/README.rdoc +0 -4
  114. data/lib/forge/app/models/comment_observer.rb +0 -9
  115. data/lib/forge/app/sweepers/page_sweeper.rb +0 -11
@@ -20,8 +20,8 @@ class Forge::HelpTopicsController < ForgeController
20
20
  @page_title = "Searching Help for: #{params[:q]}"
21
21
  q = params[:q] ? params[:q] : ""
22
22
  @help_topics = HelpTopic.where(
23
- "content LIKE :q OR title LIKE :q",
24
- {:q => q}
23
+ "LOWER(content) LIKE :q OR LOWER(title) LIKE :q",
24
+ {:q => q.downcase}
25
25
  )
26
26
  respond_to do |format|
27
27
  format.js { render :layout => false }
@@ -69,6 +69,7 @@ class Forge::PostsController < ForgeController
69
69
  end
70
70
 
71
71
  private
72
+
72
73
  def get_collections
73
74
  @categories = PostCategory.order(:title)
74
75
  end
@@ -3,10 +3,6 @@ class Forge::ProductsController < ForgeController
3
3
  before_filter :get_categories, :except => [:destroy, :reorder]
4
4
  load_and_authorize_resource :except => [:edit]
5
5
 
6
- # TODO: see if we need this stuff
7
- # before_filter :prevent_publication, :only => [:update, :create]
8
- # cache_sweeper :product_sweeper, :only => [:update, :create, :destroy]
9
-
10
6
  # GET /forge_products
11
7
  def index
12
8
  # @categories = ProductCategory.find(:all, :order => "list_order ASC")
@@ -16,7 +16,6 @@ class Forge::UsersController < ForgeController
16
16
  @user = User.new
17
17
  end
18
18
 
19
-
20
19
  def create
21
20
  @user = User.new(params[:user])
22
21
  @user.role_ids = params[:role_ids]
@@ -16,14 +16,15 @@ class ForgeController < ApplicationController
16
16
  end
17
17
 
18
18
  def get_menu_items
19
- require 'rails/application/route_inspector'
20
-
19
+ # TODO: we're really not supposed to be reading the routes like this
21
20
  # Read the routes to find out which partials to load to build the menu
22
- inspector = Rails::Application::RouteInspector.new
23
- controllers = inspector.collect_routes(Rails.application.routes.routes).select do |route|
24
- route[:reqs].match('forge')
21
+ routes = Rails.application.routes.routes
22
+ inspector = ActionDispatch::Routing::RoutesInspector.new(routes)
23
+ formatter = ActionDispatch::Routing::ConsoleFormatter.new
24
+ controllers = inspector.format(formatter).split("\n").select do |route|
25
+ route.match('forge')
25
26
  end.map do |route|
26
- route[:reqs].gsub('forge/', '').gsub(/#.*/, '')
27
+ route.gsub(/.*\)\s+/,'').gsub("forge/","").gsub(/#.*/, "")
27
28
  end
28
29
  @menu_items = controllers.reject {|c| c == "index"}.uniq!
29
30
  end
@@ -1,8 +1,6 @@
1
1
  class PostsController < ApplicationController
2
2
  before_filter :get_archive_months, :only => [:index, :category, :show]
3
3
  before_filter :get_post_categories
4
- # TODO: re-enable caching
5
- # caches_page :index, :feed
6
4
 
7
5
  def index
8
6
  @page_title = "Latest News"
@@ -1,8 +1,7 @@
1
1
  class SessionsController < Devise::SessionsController
2
2
  def new
3
- resource = build_resource
3
+ self.resource = resource_class.new(sign_in_params)
4
4
  clean_up_passwords(resource)
5
- # respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new }
6
5
  render :template => "devise/sessions/new"
7
6
  end
8
7
 
@@ -32,4 +31,4 @@ class SessionsController < Devise::SessionsController
32
31
  end
33
32
  end
34
33
  end
35
- end
34
+ end
@@ -98,8 +98,8 @@ module ForgeHelper
98
98
  def action_link(title, link, options = {})
99
99
  klass = options[:class] unless options[:class].blank?
100
100
  confirmation = options[:confirm] unless options[:confirm].blank?
101
- icon_link = link_to(icon_tag(options[:icon]), link, :confirm => confirmation) + "<br />".html_safe if options[:icon]
102
- title_link = content_tag(:small, link_to(title, link, :confirm => confirmation))
101
+ icon_link = link_to(icon_tag(options[:icon]), link, :data => { :confirm => confirmation }) + "<br />".html_safe if options[:icon]
102
+ title_link = content_tag(:small, link_to(title, link, :data => { :confirm => confirmation }))
103
103
  content = icon_link.blank? ? title_link.html_safe : icon_link.html_safe + title_link.html_safe
104
104
  return content_tag(:div, content.html_safe, :class => "item-action #{klass}")
105
105
  end
@@ -15,6 +15,9 @@ class Address < ActiveRecord::Base
15
15
  validates_presence_of :country_id
16
16
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
17
17
 
18
+ # open up everything for mass assignment
19
+ attr_protected
20
+
18
21
  def self.valid_types
19
22
  ['billing', 'shipping']
20
23
  end
@@ -1,18 +1,17 @@
1
1
  class Asset < ActiveRecord::Base
2
2
  require 'mime/types'
3
- include Sprockets::Helpers::IsolatedHelper
4
- include Sprockets::Helpers::RailsHelper
5
-
6
3
 
7
4
  acts_as_taggable
8
5
  has_attached_file :attachment, :styles => {:thumbnail => "120x108#", :medium => "800x800>"}
9
6
  before_attachment_post_process :prevent_pdf_thumbnail
10
7
 
11
-
12
- default_scope :order => "assets.created_at DESC"
8
+ default_scope { order("assets.created_at DESC") }
9
+
10
+ # open up everything for mass assignment
11
+ attr_protected
13
12
 
14
13
  def swfupload_file!(data, filename)
15
- data.content_type = MIME::Types.type_for(data.original_filename).to_s
14
+ data.content_type = MIME::Types.type_for(data.original_filename).first.content_type rescue ""
16
15
  self.attachment = data
17
16
  self.title = filename
18
17
  end
@@ -50,13 +49,13 @@ class Asset < ActiveRecord::Base
50
49
  when /image/
51
50
  attachment.url(:thumbnail)
52
51
  when /audio/
53
- asset_path "forge/asset-icons/audio.jpg"
52
+ ActionController::Base.helpers.asset_path "forge/asset-icons/audio.jpg"
54
53
  when /excel/
55
- asset_path "forge/asset-icons/spreadsheet.jpg"
54
+ ActionController::Base.helpers.asset_path "forge/asset-icons/spreadsheet.jpg"
56
55
  when /pdf/
57
- asset_path "forge/asset-icons/pdf.jpg"
56
+ ActionController::Base.helpers.asset_path "forge/asset-icons/pdf.jpg"
58
57
  else
59
- asset_path "forge/asset-icons/misc.jpg"
58
+ ActionController::Base.helpers.asset_path "forge/asset-icons/misc.jpg"
60
59
  end
61
60
  end
62
61
 
@@ -1,11 +1,13 @@
1
1
  class Banner < ActiveRecord::Base
2
2
  # Scopes, attachments, etc.
3
3
  include Forge::Reorderable
4
- scope :published, where(:published => true)
4
+ scope :published, -> { where(:published => true) }
5
5
  has_attached_file :photo, :styles => {:banner => "800x800>", :thumbnail => "120x108#"}, :default_style => :banner
6
6
  can_use_asset_for :photo
7
7
 
8
8
  # Validations
9
9
  validates_presence_of :title
10
10
  validates_attachment_presence :photo
11
+ # open up everything for mass assignment
12
+ attr_protected
11
13
  end
@@ -11,11 +11,16 @@ class Comment < ActiveRecord::Base
11
11
  attr_protected :approved
12
12
  attr_accessor :subscribe, :controller
13
13
 
14
- default_scope :order => "created_at DESC"
15
- scope :approved, where(:approved => true).order("created_at ASC")
14
+ default_scope { order("created_at DESC") }
15
+ scope :approved, -> { where(:approved => true).order("created_at ASC") }
16
+
17
+ # open up everything for mass assignment
18
+ attr_protected
16
19
 
17
20
  # Comment/uncomment this to turn off/on moderation
18
21
  # before_save :approve
22
+
23
+ after_save :handle_subscribers
19
24
 
20
25
  def self.create_comment(object, session)
21
26
  session.blank? ? Comment.new(:commentable_type => object.class.to_s, :commentable_id => object.id) : Comment.new(session)
@@ -61,4 +66,14 @@ class Comment < ActiveRecord::Base
61
66
  return "<div class='errorExplanation' id='errorExplanation'>There were problems with the following fields:<ul>#{errors}<ul></div>"
62
67
  end
63
68
 
69
+ private
70
+
71
+ def handle_subscribers
72
+ # create subscriber
73
+ CommentSubscriber.create(:commentable => self.commentable, :email => self.author_email) if self.subscribe.to_i == 1
74
+
75
+ # notify subscribers
76
+ self.commentable.subscribers.each {|subscriber| CommentMailer.comment_notification(subscriber.email, self).deliver} if self.approved?
77
+ end
78
+
64
79
  end
@@ -3,6 +3,9 @@ class CommentSubscriber < ActiveRecord::Base
3
3
  validates_uniqueness_of :email, :scope => [:commentable_id, :commentable_type]
4
4
  belongs_to :commentable, :polymorphic => true
5
5
 
6
+ # open up everything for mass assignment
7
+ attr_protected
8
+
6
9
  def list(object)
7
10
  self.where(:commentable_id => object.id, :commentable_type => object.class)
8
11
  end
@@ -4,6 +4,9 @@ class Contact
4
4
  extend ActiveModel::Naming
5
5
 
6
6
  attr_accessor :name, :email, :phone, :content, :subject
7
+
8
+ # open up everything for mass assignment
9
+ attr_protected
7
10
 
8
11
  validates_presence_of :name
9
12
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
@@ -1,7 +1,7 @@
1
1
  class Country < ActiveRecord::Base
2
2
  # Scopes, Attrs, Etc.
3
- scope :active, where(:active => true).order("top_of_list DESC, title ASC")
4
- scope :alphabetical, order("title ASC")
3
+ scope :active, -> { where(:active => true).order("top_of_list DESC, title ASC") }
4
+ scope :alphabetical, -> { order("title ASC") }
5
5
 
6
6
  # Relationships
7
7
  has_many :provinces
@@ -12,6 +12,9 @@ class Country < ActiveRecord::Base
12
12
  validates_presence_of :title, :code
13
13
  validates_uniqueness_of :title, :code
14
14
 
15
+ # open up everything for mass assignment
16
+ attr_protected
17
+
15
18
  def self.options_for_select
16
19
  Country.active.all.collect { |c| [c.title, c.id] }
17
20
  end
@@ -12,10 +12,13 @@ class Dispatch < ActiveRecord::Base
12
12
 
13
13
  validates_presence_of :subject, :content
14
14
 
15
+ # open up everything for mass assignment
16
+ attr_protected
17
+
15
18
  after_save :update_dispatch_links
16
19
 
17
20
  def deliver!(group_ids = [])
18
- subscribers = group_ids.blank? ? Subscriber.all : SubscriberGroup.find_all_by_id(group_ids).map(&:subscribers).flatten.uniq
21
+ subscribers = group_ids.blank? ? Subscriber.all : SubscriberGroup.where(id: group_ids).to_a.map(&:subscribers).flatten.uniq
19
22
  subscribers.each {|s|
20
23
  qd = QueuedDispatch.create(:subscriber => s, :dispatch => self)
21
24
  qd.send!
@@ -57,7 +60,7 @@ class Dispatch < ActiveRecord::Base
57
60
  doc = Hpricot(self.content)
58
61
  links = doc.search('a')
59
62
  links.each_with_index do |link, i|
60
- dispatch_link = DispatchLink.find_or_initialize_by_position_and_dispatch_id(i, self.id)
63
+ dispatch_link = DispatchLink.find_or_initialize_by(position: i, dispatch_id: self.id)
61
64
  dispatch_link.uri = link["href"] and dispatch_link.save!
62
65
  end
63
66
 
@@ -1,2 +1,5 @@
1
1
  class DispatchBounce < ActiveRecord::Base
2
+ # open up everything for mass assignment
3
+ attr_protected
4
+
2
5
  end
@@ -2,11 +2,14 @@ class DispatchLink < ActiveRecord::Base
2
2
  # Relationships
3
3
  belongs_to :dispatch, :foreign_key => :dispatch_id
4
4
  has_many :clicks, :class_name => "DispatchLinkClick"
5
- default_scope :order => "clicks_count DESC"
5
+ default_scope { order("clicks_count DESC") }
6
6
 
7
7
  # Validations
8
8
  # validates_presence_of :uri
9
9
  # validates_presence_of :dispatch
10
10
  # validates_uniqueness_of :position, :scope => :dispatch_id
11
11
 
12
+ # open up everything for mass assignment
13
+ attr_protected
14
+
12
15
  end
@@ -1,3 +1,7 @@
1
1
  class DispatchLinkClick < ActiveRecord::Base
2
2
  belongs_to :dispatch_link, :counter_cache => :clicks_count
3
+
4
+ # open up everything for mass assignment
5
+ attr_protected
6
+
3
7
  end
@@ -1,3 +1,7 @@
1
1
  class DispatchOpen < ActiveRecord::Base
2
- default_scope :order => "created_at DESC"
2
+ default_scope { order("created_at DESC") }
3
+
4
+ # open up everything for mass assignment
5
+ attr_protected
6
+
3
7
  end
@@ -2,4 +2,8 @@ class DispatchUnsubscribe < ActiveRecord::Base
2
2
  belongs_to :dispatch
3
3
  validates_presence_of :email
4
4
  validates_uniqueness_of :email, :scope => :dispatch_id
5
+
6
+ # open up everything for mass assignment
7
+ attr_protected
8
+
5
9
  end
@@ -1,12 +1,14 @@
1
1
  class Event < ActiveRecord::Base
2
2
  # Scopes, attachments, etc.
3
- scope :published, where(:published => true)
3
+ scope :published, -> { where(:published => true) }
4
4
  scope :upcoming, lambda { { :where => ["ends_at > ?", Time.now], :order => "starts_at" } }
5
5
  scope :past, lambda { { :where => ["ends_at < ?", Time.now], :order => "starts_at" } }
6
6
 
7
7
  attr_accessor :starts_at_date, :starts_at_time, :ends_at_date, :ends_at_time
8
8
  before_save :set_starts_at, :set_ends_at
9
9
 
10
+ # open up everything for mass assignment
11
+ attr_protected
10
12
 
11
13
  # Validations
12
14
  validates_presence_of :title
@@ -4,8 +4,11 @@ class Gallery < ActiveRecord::Base
4
4
  accepts_nested_attributes_for :photos, :allow_destroy => true, :reject_if => lambda { |p| p[:file_asset_id].blank? && p[:id].blank? }
5
5
  validates_presence_of :title
6
6
  validates_uniqueness_of :title
7
- default_scope :order => 'galleries.list_order'
7
+ default_scope { order('galleries.list_order') }
8
8
 
9
+ # open up everything for mass assignment
10
+ attr_protected
11
+
9
12
  def self.find_with_photos(id)
10
13
  includes(:photos).order('photos.list_order').find(id)
11
14
  end
@@ -3,7 +3,10 @@ class HelpTopic < ActiveRecord::Base
3
3
  validates_format_of :slug, :with => /\A[a-zA-Z0-9_-]+\z/
4
4
  validates_uniqueness_of :slug, :scope => :language
5
5
  before_save :convert_content_to_html
6
- default_scope where(:language => I18n.locale.to_s)
6
+ default_scope { where(:language => I18n.locale.to_s) }
7
+
8
+ # open up everything for mass assignment
9
+ attr_protected
7
10
 
8
11
  protected
9
12
 
@@ -24,8 +24,8 @@ class LineItem < ActiveRecord::Base
24
24
  # then enumerate through them and add up their rates
25
25
  def applicable_tax_rate(billing_address)
26
26
  raise "billing address must be an Address" unless billing_address.kind_of? Address
27
- applicable_tax_rates = self.product.tax_rates.find_all_by_country_id(billing_address.country_id)
28
- applicable_tax_rates += self.product.tax_rates.find_all_by_province_id(billing_address.province_id) if billing_address.province_id
27
+ applicable_tax_rates = self.product.tax_rates.where(country_id: billing_address.country_id).to_a
28
+ applicable_tax_rates += self.product.tax_rates.where(province_id: billing_address.province_id).to_a if billing_address.province_id
29
29
  # use uniq to ensure we don't charge tax too many times - it's possible to get overlapping rates between a country and its provinces
30
30
  applicable_tax_rates.uniq.inject(0.0) { |sum, applicable_tax_rate| sum += applicable_tax_rate.rate }
31
31
  end
@@ -14,7 +14,7 @@ class Order < ActiveRecord::Base
14
14
 
15
15
  accepts_nested_attributes_for :line_items, :reject_if => proc { |attributes| attributes['quantity'].blank? }
16
16
 
17
- scope :not_pending, where("state != 'pending'")
17
+ scope :not_pending, -> { where("state != 'pending'") }
18
18
 
19
19
  validates_presence_of :key
20
20
  validates_uniqueness_of :key
@@ -2,6 +2,9 @@ class OrderTransaction < ActiveRecord::Base
2
2
  belongs_to :order
3
3
  serialize :params
4
4
 
5
+ # open up everything for mass assignment
6
+ attr_protected
7
+
5
8
  class << self
6
9
  def authorize(amount, credit_card, options = {})
7
10
  process('authorization', amount) do |gw|
@@ -2,14 +2,14 @@ class Page < ActiveRecord::Base
2
2
  # Scopes, Attrs, Etc.
3
3
  acts_as_nested_set
4
4
  attr_protected :lft, :rgt
5
- default_scope :order => "pages.lft, pages.list_order"
6
- scope :published, where(:published => true)
7
- scope :find_for_menu, published.where("parent_id IS NULL AND show_in_menu = ?", true).includes(:subpages)
8
- scope :top, where(:parent_id => nil)
5
+ default_scope { order("pages.lft, pages.list_order") }
6
+ scope :published, -> { where(:published => true) }
7
+ scope :find_for_menu, -> { published.where("parent_id IS NULL AND show_in_menu = ?", true).includes(:subpages) }
8
+ scope :top, -> { where(:parent_id => nil) }
9
9
 
10
10
  # Relationships
11
11
  belongs_to :parent, :class_name => "Page", :foreign_key => "parent_id"
12
- has_many :subpages, :class_name => "Page", :foreign_key => "parent_id", :dependent => :destroy, :order => "list_order"
12
+ has_many :subpages, -> { order "list_order" }, :class_name => "Page", :foreign_key => "parent_id", :dependent => :destroy
13
13
 
14
14
  # Validations
15
15
  before_validation :set_slug_and_path
@@ -2,5 +2,9 @@ class Photo < ActiveRecord::Base
2
2
  belongs_to :gallery, :class_name => "Gallery", :foreign_key => "gallery_id"
3
3
  has_attached_file :file, :styles => {:thumbnail => "120x108#", :medium => "800x600>"}
4
4
  can_use_asset_for :file
5
- default_scope :order => :list_order
5
+ default_scope { order(:list_order) }
6
+
7
+ # open up everything for mass assignment
8
+ attr_protected
9
+
6
10
  end
@@ -3,7 +3,7 @@ class Post < ActiveRecord::Base
3
3
  attr_accessor :created_at_date, :created_at_time
4
4
  scope :posted, lambda { where("created_at <= ? AND published = ?", Time.now, true) }
5
5
  scope :for_archive, lambda { |year, month| where(Post.for_archive_conditions(year, month)) }
6
- default_scope :order => "created_at DESC"
6
+ default_scope { order("created_at DESC") }
7
7
 
8
8
  # Relationships
9
9
  has_and_belongs_to_many :post_categories
@@ -16,6 +16,8 @@ class Post < ActiveRecord::Base
16
16
 
17
17
  before_save :set_created_at
18
18
 
19
+ # open up everything for mass assignment
20
+ attr_protected
19
21
 
20
22
  def to_param
21
23
  "#{id}-#{title.parameterize}"