layout "project"
def show
- @wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last
+ if params[:old_page_id]
+ @wiki = @project.wikis.find(params[:old_page_id])
+ else
+ @wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last
+ end
respond_to do |format|
if @wiki
format.html
def create
@wiki = @project.wikis.new(params[:wiki])
+ @wiki.user = current_user
respond_to do |format|
if @wiki.save
end
end
end
+
+ def history
+ @wikis = @project.wikis.where(:slug => params[:id]).order("created_at")
+ end
def destroy
@wiki = @project.wikis.find(params[:id])
class Wiki < ActiveRecord::Base
belongs_to :project
+ belongs_to :user
- validates :content, :title, :presence => true
+ validates :content, :title, :user_id, :presence => true
validates :title, :length => 1..250
before_update :set_slug
--- /dev/null
+%h2 Versions
+%table
+ %thead
+ %tr
+ %th #
+ %th last edit
+ %th created by
+ %tbody
+ - @wikis.each_with_index do |wiki_page, i|
+ %tr
+ %td= i + 1
+ %td= link_to wiki_page.created_at.to_s(:short), project_wiki_path(@project, wiki_page, :old_page_id => wiki_page.id)
+ %td= wiki_page.user.name
+
%h3
= @wiki.title
- if can? current_user, :write_wiki, @project
+ = link_to history_project_wiki_path(@project, @wiki), :class => "right btn small" do
+ History
= link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do
Edit
get "files"
end
- resources :wikis, :only => [:show, :edit, :destroy, :create]
+ resources :wikis, :only => [:show, :edit, :destroy, :create] do
+ member do
+ get "history"
+ end
+ end
resource :repository do
member do
--- /dev/null
+class AddUserToWiki < ActiveRecord::Migration
+ def change
+ add_column :wikis, :user_id, :integer
+
+ end
+end
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120219140810) do
+ActiveRecord::Schema.define(:version => 20120219193300) do
create_table "issues", :force => true do |t|
t.string "title"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "slug"
+ t.integer "user_id"
end
end