Sha256: df2b479eb32fc73464cfb2c4a20beadcd7e07c5acb7eb714605fd60dabf4e8aa
Contents?: true
Size: 1.7 KB
Versions: 3
Compression:
Stored size: 1.7 KB
Contents
class ForumsController < ApplicationController before_filter :login_required, :except => [:index, :show] before_filter :find_or_initialize_forum, :except => :index #before_filter :admin?, :except => [:show, :index] def index @forums = Forum.order('position') # reset the page of each forum we have visited when we go back to index session[:forum_page] = nil respond_to do |format| format.html format.xml { render :xml => @forums } end end def show respond_to do |format| format.html do # keep track of when we last viewed this forum for activity indicators (session[:forums] ||= {})[@forum.id] = Time.now.utc if !current_user.nil? (session[:forum_page] ||= Hash.new(1))[@forum.id] = params[:page].to_i if params[:page] @topics = @forum.topics.paginate :page => params[:page] User.find(:all, :conditions => ['id IN (?)', @topics.collect { |t| t.replied_by }.uniq]) unless @topics.blank? end format.xml { render :xml => @forum } end end def create @forum.attributes = params[:forum] @forum.save! respond_to do |format| format.html { redirect_to @forum } format.xml { head :created, :location => forum_url(@forum, :format => :xml) } end end def update @forum.update_attributes!(params[:forum]) respond_to do |format| format.html { redirect_to @forum } format.xml { head 200 } end end def destroy @forum.destroy respond_to do |format| format.html { redirect_to forums_path } format.xml { head 200 } end end protected def find_or_initialize_forum @forum = params[:id] ? Forum.find(params[:id]) : Forum.new end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tamed_beast-0.0.3 | app/controllers/forums_controller.rb |
tamed_beast-0.0.2 | app/controllers/forums_controller.rb |
tamed_beast-0.0.1 | app/controllers/forums_controller.rb |