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
- #duplicate ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/sibu/sites_controller.rb', line 21 def create @site = Sibu::Site.new(site_params) if @site.save_and_init generate_styles(@site) if conf[:custom_styles] 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
47 48 49 50 |
# File 'app/controllers/sibu/sites_controller.rb', line 47 def destroy @site.destroy redirect_to sites_url, notice: "Le site a bien été supprimé." end |
#duplicate ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/sibu/sites_controller.rb', line 52 def duplicate new_site = @site.deep_copy if new_site.save if conf[:custom_styles] generate_styles(@site) generate_styles(new_site) end redirect_to sites_url, notice: "Le site a bien été copié." else flash.now[:alert] = "Une erreur s'est produite lors de la copie du site." render :index end end |
#edit ⇒ Object
32 33 |
# File 'app/controllers/sibu/sites_controller.rb', line 32 def edit end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/sibu/sites_controller.rb', line 8 def index @sites = Sibu::Site.for_user(sibu_user).order(:name, :version) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/sibu/sites_controller.rb', line 17 def new @site = Sibu::Site.new(user_id: sibu_user.id, version: Sibu::Site::DEFAULT_VERSION) 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 43 44 45 |
# File 'app/controllers/sibu/sites_controller.rb', line 35 def update if @site.update(site_params) if conf[:custom_styles] && @site.previous_changes.has_key?(:custom_data) generate_styles(@site) end redirect_to sites_url, 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 |