Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

convert to strong params for rails 4

  • Loading branch information...
commit 7985a31bb0071cd837c01866c7a41cbfc65e7fb0 1 parent 7e71c70
@onyxrev onyxrev authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.