Class: Admin::SitesController
- Defined in:
- app/controllers/admin/sites_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/admin/sites_controller.rb', line 19 def create site = Site.new params[:site] section = site.sections.build(params[:section]) site.sections << section if site.save flash[:notice] = t(:'adva.sites.flash.create.success') redirect_to admin_site_url(site) else flash.now[:error] = t(:'adva.sites.flash.create.failure') render :action => :new end end |
#destroy ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/admin/sites_controller.rb', line 46 def destroy if @site.destroy flash[:notice] = t(:'adva.sites.flash.destroy.success') redirect_to return_from(:site_deleted) else flash.now[:error] = t(:'adva.sites.flash.destroy.failure') render :action => 'show' end end |
#edit ⇒ Object
33 34 |
# File 'app/controllers/admin/sites_controller.rb', line 33 def edit end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/admin/sites_controller.rb', line 6 def index @sites = Site.paginate(:page => params[:page], :per_page => params[:per_page]).order(:id) end |
#new ⇒ Object
16 17 |
# File 'app/controllers/admin/sites_controller.rb', line 16 def new end |
#show ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/admin/sites_controller.rb', line 10 def show @users = @site.users @contents = @site.unapproved_comments.group_by(&:commentable) if @site.respond_to?(:unapproved_comments) @activities = @site.grouped_activities end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/admin/sites_controller.rb', line 36 def update if @site.update params[:site] flash[:notice] = t(:'adva.sites.flash.update.success') redirect_to edit_admin_site_url else flash.now[:error] = t(:'adva.sites.flash.update.failure') render :action => 'edit' end end |