wikis_controller.rb
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class WikisController < ApplicationController
before_filter :project
layout "project"
respond_to :html
def show
@wiki = @project.wikis.find_by_slug(params[:id])
respond_with(@wiki)
end
def new
@wiki = Wiki.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @wiki }
end
end
def edit
@wiki = Wiki.find(params[:id])
end
def create
@wiki = Wiki.new(params[:wiki])
respond_to do |format|
if @wiki.save
format.html { redirect_to @wiki, notice: 'Wiki was successfully created.' }
format.json { render json: @wiki, status: :created, location: @wiki }
else
format.html { render action: "new" }
format.json { render json: @wiki.errors, status: :unprocessable_entity }
end
end
end
def update
@wiki = Wiki.find(params[:id])
respond_to do |format|
if @wiki.update_attributes(params[:wiki])
format.html { redirect_to @wiki, notice: 'Wiki was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @wiki.errors, status: :unprocessable_entity }
end
end
end
def destroy
@wiki = Wiki.find(params[:id])
@wiki.destroy
respond_to do |format|
format.html { redirect_to wikis_url }
format.json { head :no_content }
end
end
end