Class: Sibu::SitesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Sibu::SitesController
- Defined in:
- app/controllers/sibu/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
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/sibu/sites_controller.rb', line 21 def create @site = Sibu::Site.new(site_params) if @site.save_and_init redirect_to sites_url, notice: "Le site a bien été créé." else flash.now[:alert] = "Une erreur s'est produite lors de la création du site." render :new end end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/sibu/sites_controller.rb', line 44 def destroy @site.destroy redirect_to sites_url, notice: "Le site a bien été supprimé." end |
#edit ⇒ Object
31 32 33 |
# File 'app/controllers/sibu/sites_controller.rb', line 31 def edit @next_page = params[:next_page] end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/sibu/sites_controller.rb', line 8 def index @sites = Sibu::Site.where(user_id: send(Rails.application.config.sibu[:current_user]).id) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/sibu/sites_controller.rb', line 17 def new @site = Sibu::Site.new(user_id: send(Rails.application.config.sibu[:current_user]).id) end |
#show ⇒ Object
12 13 14 15 |
# File 'app/controllers/sibu/sites_controller.rb', line 12 def show @page = @site.page('') redirect_to site_page_path(@site.id, @page.id) end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/sibu/sites_controller.rb', line 35 def update if @site.update(site_params) redirect_to (params[:next_page].blank? ? sites_url : params[:next_page]), notice: "Le site a bien été mis à jour." else flash.now[:alert] = "Une erreur s'est produite lors de l'enregistrement du site." render :edit end end |