Class: Forge::PostsController
Instance Method Summary
collapse
#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor
#app_init
Instance Method Details
#create ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 35
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.html { redirect_to(forge_posts_path, :notice => 'Post was successfully created.') }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
|
#destroy ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 62
def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to(forge_posts_path) }
format.xml { head :ok }
end
end
|
#edit ⇒ Object
32
33
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 32
def edit
end
|
#index ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 6
def index
respond_to do |format|
format.html { @posts = Post.paginate(:per_page => 10, :page => params[:page]) }
format.js {
@posts = Post.where("title LIKE :q OR content LIKE :q", {:q => "%#{params[:q]}%"})
render :partial => "post", :collection => @posts
}
end
end
|
#new ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 23
def new
@post = Post.new
@help = HelpTopic.where(:slug => "posts_new").first
respond_to do |format|
format.html format.xml { render :xml => @post }
end
end
|
#show ⇒ Object
16
17
18
19
20
21
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 16
def show
respond_to do |format|
format.html format.xml { render :xml => @post }
end
end
|
#update ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/forge/app/controllers/forge/posts_controller.rb', line 49
def update
params[:post][:post_category_ids] ||= []
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to(forge_posts_path, :notice => 'Post was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
|