make design work with layout and testing with package andreas05 within r tag

This commit is contained in:
Kaito 2011-08-01 18:17:28 +08:00
parent b6db304579
commit c8d58e30aa
4 changed files with 9 additions and 4 deletions

View File

@ -9,7 +9,6 @@ gem 'ckeditor'
gem 'devise' gem 'devise'
gem 'mini_magick' gem 'mini_magick'
gem 'nokogiri'
gem 'mongoid' gem 'mongoid'

View File

@ -25,9 +25,13 @@ class Admin::DesignsController < ApplicationController
def apply def apply
@design = Design.find(params[:id]) @design = Design.find(params[:id])
Layout.create(:name => @design.title,:description=>@design.intro,:content=>@design.layout.file.read)
#TODO do somehting to validate #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 end
def edit_file def edit_file

View File

@ -6,9 +6,11 @@ class Layout
field :name, :index => true field :name, :index => true
field :description field :description
field :content field :content
field :parent_id
references_many :children, :class_name => "Item" references_many :children, :class_name => "Item"
has_many :layout_parts has_many :layout_parts
belongs_to :design,:class_name=>"Design"
validates_presence_of :name validates_presence_of :name
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/ validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/

View File

@ -9,4 +9,4 @@
$(this).children('.edit_link').toggle(); $(this).children('.edit_link').toggle();
}); });
</script> </script>
<% end -%> <% end -%>