Class: RailsBlogEngine::PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsBlogEngine::PostsController
- Defined in:
- app/controllers/rails_blog_engine/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 18 def create @post. = current_user @post.publish if @post.save redirect_to(post_permalink_path(@post), :notice => "Post was successfully created.") else render :action => :new end end |
#edit ⇒ Object
34 35 |
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 34 def edit end |
#index ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 8 def index respond_to do |format| format.html { @posts = @posts.page(params[:page]).per(5) } format.atom { @posts = @posts.limit(15) } end end |
#new ⇒ Object
15 16 |
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 15 def new end |
#show ⇒ Object
29 30 31 32 |
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 29 def show @comments = comments_to_display.order(:created_at) @comment = Comment.new {|c| c.post = @post } end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 37 def update @post.update_attributes(params[:post]) if @post.save redirect_to(post_permalink_path(@post), :notice => "Post was successfully updated.") else render :action => :edit end end |