Class: IshLibManager::SitesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshLibManager::SitesController
- Defined in:
- app/controllers/ish_lib_manager/sites_controller.rb
Constant Summary collapse
- PERMITTED_ATTRIBUTES =
[ :domain, :lang, :title, :subhead, :homepage_layout, :layout, :n_features, :n_newsitems, :is_trash, :is_ads_enabled, :is_private, :home_redirect_path, :is_video_enabled, :is_resume_enabled, :is_primary ]
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #newsitem_delete ⇒ Object
- #show ⇒ Object
- #trash ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 42 def create :create, Site.new @site = Site.new params[:site].permit( PERMITTED_ATTRIBUTES ) if @site.save flash[:notice] = 'Success' else flash[:error] = 'No Luck. ' + @site.errors.inspect end redirect_to manager_sites_path end |
#edit ⇒ Object
32 33 34 35 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 32 def edit @site = Site.find params[:id] :edit, @site end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 9 def index :index, Site @sites = Site.all.order_by( :domainname => :desc, :lang => :desc ) end |
#new ⇒ Object
37 38 39 40 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 37 def new :new, Site.new @site = Site.new end |
#newsitem_delete ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 65 def newsitem_delete @site = Site.find params[:site_id] :update, @site n = @site.newsitems.find( params[:newsitem_id] ) n.delete @site.save flash[:notice] = 'Probably successfully deleted a newsitem.' redirect_to manager_site_path( @site.id ) end |
#show ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 20 def show @site = Site.find params[:id] :show, @site @galleries = @site.galleries.unscoped.where({ :is_trash => false }).page( params[:galleries_page] ).per( 10 ) @reports = @site.reports.unscoped.where({ :is_trash => false }).page( params[:reports_page] ).per( 10 ) @videos = @site.videos.page( params[:videos_page] ).per( 5 ) @tags = @site..page( params[:tags_page] ).per( 100 ) @features = @site.features.page( params[:features_page] ).per( 9 ) @newsitems = @site.newsitems.page( params[:newsitems_page] ).per( 10 ) end |
#trash ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 14 def trash :trash, Site @sites = Site.unscoped.where( :is_trash => true ).order_by( :domainname => :desc, :lang => :desc ) render :action => :index end |
#update ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/ish_lib_manager/sites_controller.rb', line 53 def update @site = Site.find params[:id] :update, @site if @site.update_attributes params[:site].permit( PERMITTED_ATTRIBUTES ) flash[:notice] = 'Success' else flash[:error] = 'No Luck' end redirect_to sites_path end |