blob: 649305f16b93638e7b6c9b9b2c55dee7ee9474d8 (
plain)
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
|
class TutorialsController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :index]
def index
@tutorials = Tutorial.all
end
def show
@tutorial = Tutorial.find(params[:id])
end
def new
@tutorial = Tutorial.new
end
def edit
@tutorial = current_user.tutorials.find(params[:id])
end
def create
@tutorial = current_user.tutorials.create(params[:tutorial])
respond_to do |format|
if @tutorial.save
format.html { redirect_to( '/tutorials' ) }
else
flash[:error] = @tutorial.errors.full_messages
format.html { render :action => "new" }
end
end
end
def update
@tutorial = current_user.tutorials.find(params[:id])
respond_to do |format|
if @tutorial.update_attributes(params[:tutorial])
format.html { redirect_to(@tutorial, :notice => 'tutorial was successfully updated.') }
else
format.html { render :action => "edit" }
end
end
end
def destroy
@tutorial = current_user.tutorials.find(params[:id])
@tutorial.destroy
respond_to do |format|
format.html { redirect_to(tutorials_url) }
end
end
end
|