Class: Guts::SitesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Guts::SitesController
- 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 included from MultisiteConcern
#current_site, #with_current_site
Methods included from SessionsHelper
#current_user, #log_in, #log_out, #logged_in?
Instance Method Details
#create ⇒ Object
Note:
Redirects to #index if successfull or re-renders #new if not
Creates a site through post
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/guts/sites_controller.rb', line 28 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
52 53 54 55 |
# File 'app/controllers/guts/sites_controller.rb', line 52 def destroy @site.destroy redirect_to sites_url, notice: 'Site was successfully destroyed.' end |
#edit ⇒ Object
Editting of a site
23 24 |
# File 'app/controllers/guts/sites_controller.rb', line 23 def edit end |
#index ⇒ Object
Displays a list of sites
9 10 11 |
# File 'app/controllers/guts/sites_controller.rb', line 9 def index @sites = Site.all end |
#new ⇒ Object
Creation of a site
18 19 20 |
# File 'app/controllers/guts/sites_controller.rb', line 18 def new @site = Site.new end |
#remove_default ⇒ Object
Removes a site as default
69 70 71 72 73 74 |
# File 'app/controllers/guts/sites_controller.rb', line 69 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
58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/guts/sites_controller.rb', line 58 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
14 15 |
# File 'app/controllers/guts/sites_controller.rb', line 14 def show end |
#update ⇒ Object
Note:
Redirects to #index if successfull or re-renders #edit if not
Updates a site through patch
41 42 43 44 45 46 47 48 |
# File 'app/controllers/guts/sites_controller.rb', line 41 def update if @site.update site_params flash[:notice] = 'Site was successfully updated.' redirect_to sites_url else render :edit end end |