diff --git a/app/models/page.rb b/app/models/page.rb index c5f48d43..9861c6e9 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -25,7 +25,7 @@ class Page < ActiveRecord::Base if (revisions_size > 0) && continous_revision?(time, author) current_revision.update_attributes(:content => content, :revised_at => time) else - revisions.create(:content => content, :author => author, :revised_at => time) + revisions.build(:content => content, :author => author, :revised_at => time) end save self diff --git a/lib/page_renderer.rb b/lib/page_renderer.rb index af64602c..2e3e5a64 100644 --- a/lib/page_renderer.rb +++ b/lib/page_renderer.rb @@ -116,19 +116,19 @@ class PageRenderer else link_type = WikiReference.link_type(@revision.page.web, referenced_name) end - references.create :referenced_name => referenced_name, :link_type => link_type + references.build :referenced_name => referenced_name, :link_type => link_type end include_chunks = rendering_result.find_chunks(Include) includes = include_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq includes.each do |included_page_name| - references.create :referenced_name => included_page_name, + references.build :referenced_name => included_page_name, :link_type => WikiReference::INCLUDED_PAGE end categories = rendering_result.find_chunks(Category).map { |cat| cat.list }.flatten categories.each do |category| - references.create :referenced_name => category, :link_type => WikiReference::CATEGORY + references.build :referenced_name => category, :link_type => WikiReference::CATEGORY end end end