Newer
Older
danielvincent
a validé
class BlogsController < ApplicationController
danielvincent
a validé
def index
@blogs = Blog.criteria.all.order_by( [:created_at, :desc] )
danielvincent
a validé
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
end
def show
@blog = Blog.find(params[:id])
end
def new
@blog = Blog.new
end
def create
@blog = Blog.new(params[:blog])
if @blog.save
flash[:notice] = "Successfully created blog."
redirect_to @blog
else
render :action => 'new'
end
end
def edit
@blog = Blog.find(params[:id])
end
def update
@blog = Blog.find(params[:id])
if @blog.update_attributes(params[:blog])
flash[:notice] = "Successfully updated blog."
redirect_to @blog
else
render :action => 'edit'
end
end
def destroy
@blog = Blog.find(params[:id])
@blog.destroy
flash[:notice] = "Successfully destroyed blog."
redirect_to blogs_url
end
end