Permalink
Browse files

Merge pull request #13 from onyxrev/master

Updates for compatibility with Rails 4 and Spree 2.1
  • Loading branch information...
2 parents 6ba8486 + f8cc3f1 commit d9dc6f7637dfe50d71507bac8aec24633616ec17 @sebastyuiop committed Feb 3, 2014
@@ -1,8 +1,5 @@
module Spree
class Admin::PagesController < Admin::ResourceController
-
- cache_sweeper PageSweeper, :only => [ :edit, :update, :destroy ]
-
def index
@pages = Page.page(params[:page])
end
@@ -12,7 +9,7 @@ def new
end
def create
- @page = Page.new(params[:page])
+ @page = Page.new(pages_params)
if @page.save
flash[:notice] = "Successfully created page."
redirect_to admin_pages_url
@@ -27,7 +24,7 @@ def edit
def update
@page = Page.find(params[:id])
- if @page.update_attributes(params[:page])
+ if @page.update_attributes(pages_params)
flash[:notice] = "Successfully updated page."
redirect_to admin_pages_url
else
@@ -52,5 +49,11 @@ def destroy
end
end
end
+
+ protected
+
+ def pages_params
+ params.require(:page).permit(:title, :meta_keywords, :meta_description, :body, :permalink, :published)
+ end
end
end
@@ -1,8 +1,10 @@
module Spree
class PagesController < BaseController
- before_filter { render_404 if params[:id] =~ /(\.|\\)/ }
+ include Spree::Core::ControllerHelpers::Order
+
+ layout 'spree/layouts/spree_application'
- caches_action :show, :if => Proc.new { Config[:cache_static_content] }, :layout => false
+ before_filter { render_404 if params[:id] =~ /(\.|\\)/ }
respond_to :html
@@ -0,0 +1,5 @@
+module PagesHelper
+ include Spree::StoreHelper
+ include Spree::ProductsHelper
+end
+
View
@@ -1,6 +1,5 @@
module Spree
class Page < ActiveRecord::Base
- attr_accessible :title, :meta_keywords, :meta_description, :body, :permalink, :published
validates :title, :presence => true
validates :permalink, :uniqueness => true
@@ -1,6 +1,6 @@
Deface::Override.new(
:name => "add_pages_tab_to_admin",
- :virtual_path => "spree/layouts/admin",
+ :virtual_path => "spree/admin/shared/_menu",
:insert_bottom => "[data-hook='admin_tabs']",
:text => %(<%= tab(:pages) %>)
)
@@ -1,20 +0,0 @@
-module Spree
- class PageSweeper < ActionController::Caching::Sweeper
- observe Page
-
- def after_update(page)
- expire_page_cache(page)
- end
-
- def after_destroy(page)
- expire_page_cache(page)
- end
-
- private
-
- def expire_page_cache(page)
- expire_action(:controller => 'pages', :action => 'show', :id => page.permalink)
- end
-
- end
-end
@@ -14,6 +14,10 @@ def self.activate
end
end
+ config.to_prepare do
+ ApplicationController.helper(PagesHelper)
+ end
+
config.to_prepare &method(:activate).to_proc
end
end
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_pages'
- s.version = '0.60.0'
+ s.version = '0.70.0'
s.summary = 'Adds a basic CMS to Spree'
s.description = 'Simple page based CMS for Spree'
s.required_ruby_version = '>= 1.8.7'
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency('spree_core', '>= 1.0')
+ s.add_dependency('spree_core', '~> 2.1')
end

0 comments on commit d9dc6f7

Please sign in to comment.