Sha256: 792b0852866c2fbeebccb62e38b75c9eab0737c8fb798bd5f2588950b768f5cd
Contents?: true
Size: 954 Bytes
Versions: 3
Compression:
Stored size: 954 Bytes
Contents
class PostsController < ApplicationController #unloadable include Authentication before_filter :login_required, :except => [:index, :show] def index @posts = Post.all end def show @post = Post.find(params[:id]) end def new @post = Post.new end def create @post = Post.new(params[:post]) @post.user = current_user if @post.save flash[:notice] = "Successfully created post." redirect_to @post else render :action => 'new' end end def edit @post = Post.find(params[:id]) end def update @post = Post.find(params[:id]) if @post.update_attributes(params[:post]) flash[:notice] = "Successfully updated post." redirect_to @post else render :action => 'edit' end end def destroy @post = Post.find(params[:id]) @post.destroy flash[:notice] = "Successfully destroyed post." redirect_to posts_url end end
Version data entries
3 entries across 3 versions & 1 rubygems