Created
October 20, 2010 13:23
-
-
Save TaopaiC/636388 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ForumsController < ApplicationController | |
before_filter :find_forum, :except => [:index, :new, :create] | |
def index | |
@forums = Forum.all | |
end | |
def show | |
redirect_to forum_path(@forum) | |
end | |
def new | |
@forum = Forum.new | |
end | |
def create | |
@forum = Forum.new(params[:forum]) | |
if @forum.save | |
redirect_to forum_path(@forum) | |
else | |
render :new | |
end | |
end | |
def edit | |
end | |
def update | |
if @forum.update_attribute(params[:forum]) | |
redirect_to forum_path(@forum) | |
else | |
render :edit | |
end | |
end | |
def destroy | |
@forum.destroy | |
redirect_to forums_path | |
end | |
protected | |
def find_forum | |
@forum = Forum.find(params[:id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment