Permalink
Browse files

convert to strong params for rails 4

  • Loading branch information...
1 parent 7e71c70 commit 7985a31bb0071cd837c01866c7a41cbfc65e7fb0 @onyxrev onyxrev committed Dec 7, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −2 app/controllers/spree/admin/pages_controller.rb
  2. +0 −1 app/models/spree/page.rb
View
10 app/controllers/spree/admin/pages_controller.rb
@@ -9,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
@@ -24,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
@@ -49,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
View
1 app/models/spree/page.rb
@@ -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

0 comments on commit 7985a31

Please sign in to comment.