From c8d58e30aa5b9e2b2838306443f4fdafa1556ab6 Mon Sep 17 00:00:00 2001 From: Kaito Date: Mon, 1 Aug 2011 18:17:28 +0800 Subject: [PATCH] make design work with layout and testing with package andreas05 within r tag --- Gemfile | 1 - app/controllers/admin/designs_controller.rb | 8 ++++++-- app/models/layout.rb | 2 ++ app/views/admin/pages/_show.html.erb | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 441a780c..4ba1051a 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,6 @@ gem 'ckeditor' gem 'devise' gem 'mini_magick' -gem 'nokogiri' gem 'mongoid' diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 1b899ea3..7aa93526 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -25,9 +25,13 @@ class Admin::DesignsController < ApplicationController def apply @design = Design.find(params[:id]) + Layout.create(:name => @design.title,:description=>@design.intro,:content=>@design.layout.file.read) #TODO do somehting to validate - debugger - doc = Nokogiri::HTML(@design.layout.file.read) +# doc = Nokogiri::HTML(@design.layout.file.read) + flash[:notice] = "Successfully applied design and created a layout." + + redirect_to admin_designs_url + end def edit_file diff --git a/app/models/layout.rb b/app/models/layout.rb index 53da1f35..20a2a46f 100644 --- a/app/models/layout.rb +++ b/app/models/layout.rb @@ -6,9 +6,11 @@ class Layout field :name, :index => true field :description field :content + field :parent_id references_many :children, :class_name => "Item" has_many :layout_parts + belongs_to :design,:class_name=>"Design" validates_presence_of :name validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/ diff --git a/app/views/admin/pages/_show.html.erb b/app/views/admin/pages/_show.html.erb index 2bc1d1f4..39905cbf 100644 --- a/app/views/admin/pages/_show.html.erb +++ b/app/views/admin/pages/_show.html.erb @@ -9,4 +9,4 @@ $(this).children('.edit_link').toggle(); }); -<% end -%> \ No newline at end of file +<% end -%>