Sha256: 6bd419645709a3db72537366f68e74490803e1f9ac641448221a65650161d82f
Contents?: true
Size: 1.58 KB
Versions: 5
Compression:
Stored size: 1.58 KB
Contents
class SitesController < ApplicationController before_filter :remove_methods, :only => [:new, :create, :destroy] before_filter :find_site, :except => [:index, :create, :new] before_filter :visitor_node before_filter :check_is_admin layout :admin_layout def index secure!(Site) do @sites = Site.paginate(:all, :order => 'host', :per_page => 20, :page => params[:page]) end respond_to do |format| format.html # index.erb format.xml { render :xml => @sites } end end def show respond_to do |format| format.html format.xml { render :xml => @site } format.js end end def edit respond_to do |format| format.html format.js { render :partial => 'sites/form', :layout => false } end end def update respond_to do |format| if @site.update_attributes(params[:site]) flash.now[:notice] = _('Site was successfully updated.') format.html { redirect_to site_path(@site) } format.js format.xml { head :ok } else format.html { render :action => "edit" } format.js format.xml { render :xml => @site.errors } end end end def action if Site::ACTIONS.include?(params[:do]) @site.send(params[:do]) flash.now[:notice] = _("#{params[:do]} done.") else flash.now[:error] = _("Invalid action '%{action}'.") % {:action => params[:do]} end end protected def remove_methods raise ActiveRecord::RecordNotFound end def find_site @site = secure!(Site) { Site.find(params[:id])} end end
Version data entries
5 entries across 5 versions & 1 rubygems