Skip to content

Commit

Permalink
Say goodbye to hash rockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
futhr committed Dec 29, 2014
1 parent 2d9d8d0 commit dbf4f0a
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/controllers/spree/static_content_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Spree::StaticContentController < Spree::StoreController
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404

helper 'spree/products'
layout :determine_layout
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/spree/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ def render_snippet(slug)
page = Spree::Page.find_by_slug(slug)
raw page.body if page
end
end
end
18 changes: 9 additions & 9 deletions app/models/spree/page.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
class Spree::Page < ActiveRecord::Base
default_scope -> { order("position ASC") }

has_and_belongs_to_many :stores, :join_table => 'spree_pages_stores'
has_and_belongs_to_many :stores, join_table: 'spree_pages_stores'

validates_presence_of :title
validates_presence_of [:slug, :body], :if => :not_using_foreign_link?
validates_presence_of :layout, :if => :render_layout_as_partial?
validates_presence_of [:slug, :body], if: :not_using_foreign_link?
validates_presence_of :layout, if: :render_layout_as_partial?

validates :slug, :uniqueness => true, :if => :not_using_foreign_link?
validates :foreign_link, :uniqueness => true, :allow_blank => true
validates :slug, uniqueness: true, if: :not_using_foreign_link?
validates :foreign_link, uniqueness: true, allow_blank: true

scope :visible, -> { where(:visible => true) }
scope :header_links, -> { where(:show_in_header => true).visible }
scope :footer_links, -> { where(:show_in_footer => true).visible }
scope :sidebar_links, -> { where(:show_in_sidebar => true).visible }
scope :visible, -> { where(visible: true) }
scope :header_links, -> { where(show_in_header: true).visible }
scope :footer_links, -> { where(show_in_footer: true).visible }
scope :sidebar_links, -> { where(show_in_sidebar: true).visible }

scope :by_store, lambda { |store| joins(:stores).where("spree_pages_stores.store_id = ?", store) }

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
resources :pages
end
constraints(Spree::StaticPage) do
get '/(*path)', :to => 'static_content#show', :as => 'static'
get '/(*path)', to: 'static_content#show', as: 'static'
end
end
6 changes: 3 additions & 3 deletions db/migrate/20090625125735_extend_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class Page < ActiveRecord::Base

def self.up
change_table :spree_pages do |t|
t.boolean :show_in_header, :default => false, :null => false
t.boolean :show_in_footer, :default => false, :null => false
t.boolean :show_in_header, default: false, null: false
t.boolean :show_in_footer, default: false, null: false
t.string :foreign_link
t.integer :position, :default => 1, :null => false
t.integer :position, default: 1, null: false
if Page.table_exists?
Page.order(:updated_at).each_with_index{|page,x| page.update_attribute(:position, x+1)}
else
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20090814113100_add_visible_to_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class Page < ActiveRecord::Base
def self.up
add_column :spree_pages, :visible, :boolean
if Page.table_exists?
Page.update_all :visible => true
Page.update_all visible: true
else
Spree::Page.update_all :visible => true
Spree::Page.update_all visible: true
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class AddDefaultTrueToVisibleForPage < ActiveRecord::Migration
def self.up
change_column :spree_pages, :visible, :boolean, :default=> true
change_column :spree_pages, :visible, :boolean, default: true
end

def self.down
end
end
end
1 change: 0 additions & 1 deletion db/migrate/20090829000527_add_index_for_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ def self.down
remove_index(:spree_pages, :slug)
end
end

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class AddShowInSidebarOptionToPages < ActiveRecord::Migration
def self.up
add_column :spree_pages, :show_in_sidebar, :boolean, :default=> false, :null=>false
add_column :spree_pages, :show_in_sidebar, :boolean, default: false, null: false
end

def self.down
remove_column :spree_pages, :show_in_sidebar
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AddRenderAsPartialForLayoutForSpreePages < ActiveRecord::Migration
def up
unless column_exists? :spree_pages, :render_layout_as_partial
add_column :spree_pages, :render_layout_as_partial, :boolean, :default => false
add_column :spree_pages, :render_layout_as_partial, :boolean, default: false
end
end

Expand Down
4 changes: 1 addition & 3 deletions db/migrate/20140926121757_add_pages_stores.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
class AddPagesStores < ActiveRecord::Migration

def change
create_table :spree_pages_stores, :id => false do |t|
create_table :spree_pages_stores, id: false do |t|
t.integer :store_id
t.integer :page_id
t.timestamps
end

add_index :spree_pages_stores, :store_id
add_index :spree_pages_stores, :page_id

end
end
2 changes: 1 addition & 1 deletion spec/factories/page_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
foreign_link { Faker::Internet.http_url }
end
end
end
end

0 comments on commit dbf4f0a

Please sign in to comment.