app/controllers/spud/admin/pages_controller.rb in spud_cms-0.9.21 vs app/controllers/spud/admin/pages_controller.rb in spud_cms-1.0.0.RC1

- old
+ new

@@ -6,14 +6,16 @@ def index @pages = SpudPage.site(session[:admin_site]).where(:spud_page_id => nil).order(:page_order).includes(:spud_pages).paginate :page => params[:page] - home_page = SpudPage.where(:url_name => Spud::Cms.root_page_name).first - if home_page.blank? - flash.now[:warning] = "You have not setup your default CMS page. This page will be your homepage. To do so, create a page with the name '#{Spud::Cms.root_page_name.titlecase}'" - end + if Spud::Cms.root_page_name + home_page = SpudPage.where(:url_name => Spud::Cms.root_page_name).first + if home_page.blank? + flash.now[:warning] = "You have not setup your default CMS page. This page will be your homepage. To do so, create a page with the name '#{Spud::Cms.root_page_name.titlecase}'" + end + end respond_with @pages end def show @@ -37,11 +39,11 @@ respond_with @page end def create - @page = SpudPage.new(params[:spud_page]) + @page = SpudPage.new(page_params) @page.site_id = session[:admin_site] if params[:preview] && params[:preview].to_i == 1 preview return end @@ -69,11 +71,11 @@ end def update - @page.attributes = params[:spud_page] + @page.attributes = page_params if params[:preview] && params[:preview].to_i == 1 preview return end if @page.save @@ -174,9 +176,14 @@ flash[:warning] = "Site Context Changed. The page you were viewing is not associated with the current site. Redirected back to page selections." redirect_to spud_admin_pages_url() and return false end return true end + + + def page_params + params.require(:spud_page).permit(:name,:url_name,:created_by,:updated_by,:layout,:visibility,:spud_page_id,:publish_at,:format,:meta_description,:meta_keywords,:page_order,{:spud_page_partials_attributes => [:id,:name, :content, :format]},:use_custom_url_name,:published,:notes) + end end