From 8b576cac485d3e24abbcb4b288a141c8450643cc Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 25 Aug 2011 15:44:52 +0800 Subject: [PATCH] Fix bug when selecting theme --- app/models/page.rb | 2 +- lib/parser.rb | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index be51c35c..4e9f87ff 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,7 +1,7 @@ class Page < Item field :content - field :theme_id + field :theme_id, :type => BSON::ObjectId belongs_to :design has_many :page_parts diff --git a/lib/parser.rb b/lib/parser.rb index d55b3cdf..c8fc1940 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -66,10 +66,8 @@ module Parser c.define_tag 'stylesheets' do |tag| res = '' res << " " - page.design.themes.each do |theme| - res << " " - end - res + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + res << "" end c.define_tag 'javascripts' do |tag| res = '' @@ -171,10 +169,8 @@ module Parser c.define_tag 'stylesheets' do |tag| res = '' res << "" - page.design.themes.each do |theme| - res << "" - end - res + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + res << "" end c.define_tag 'javascripts' do |tag| res = ''