Class: Guts::SitesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Guts::SitesController
- Includes:
- ControllerPermissionConcern
- Defined in:
- app/controllers/guts/sites_controller.rb
Overview
Sites controller
Instance Method Summary collapse
-
#create ⇒ Object
Creates a site through post.
-
#destroy ⇒ Object
Destroys a site.
-
#edit ⇒ Object
Editting of a site.
-
#index ⇒ Object
Displays a list of sites.
-
#new ⇒ Object
Creation of a site.
-
#remove_default ⇒ Object
Removes a site as default.
-
#set_default ⇒ Object
Sets a site as default.
-
#show ⇒ Object
Shows detaisl about a single site.
-
#update ⇒ Object
Updates a site through patch.
Methods inherited from ApplicationController
Methods included from MultisiteConcern
#current_site, #with_current_site
Instance Method Details
#create ⇒ Object
Note:
Redirects to #index if successfull or re-renders #new if not
Creates a site through post
31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/guts/sites_controller.rb', line 31 def create @site = Site.new site_params if @site.save flash[:notice] = 'Site was successfully created.' redirect_to sites_url else render :new end end |
#destroy ⇒ Object
Note:
Redirects to #index on success
Destroys a site
55 56 57 58 |
# File 'app/controllers/guts/sites_controller.rb', line 55 def destroy @site.destroy redirect_to sites_url, notice: 'Site was successfully destroyed.' end |
#edit ⇒ Object
Editting of a site
26 27 |
# File 'app/controllers/guts/sites_controller.rb', line 26 def edit end |
#index ⇒ Object
Displays a list of sites
12 13 14 |
# File 'app/controllers/guts/sites_controller.rb', line 12 def index @sites = Site.all end |
#new ⇒ Object
Creation of a site
21 22 23 |
# File 'app/controllers/guts/sites_controller.rb', line 21 def new @site = Site.new end |
#remove_default ⇒ Object
Removes a site as default
72 73 74 75 76 77 |
# File 'app/controllers/guts/sites_controller.rb', line 72 def remove_default @site.update_attribute(:default, false) flash[:notice] = 'Site was successfully changed to not default.' redirect_to sites_url end |
#set_default ⇒ Object
Sets a site as default
61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/guts/sites_controller.rb', line 61 def set_default old_default = Site.find_by(default: true) old_default.update_attribute(:default, false) unless old_default.nil? @site.update_attribute(:default, true) flash[:notice] = 'Site was successfully set to default.' redirect_to sites_url end |
#show ⇒ Object
Shows detaisl about a single site
17 18 |
# File 'app/controllers/guts/sites_controller.rb', line 17 def show end |
#update ⇒ Object
Note:
Redirects to #index if successfull or re-renders #edit if not
Updates a site through patch
44 45 46 47 48 49 50 51 |
# File 'app/controllers/guts/sites_controller.rb', line 44 def update if @site.update site_params flash[:notice] = 'Site was successfully updated.' redirect_to sites_url else render :edit end end |