Sha256: 5e062bb7749ddf6abeb3c7723b4b64f98c807c69ab35b211097a5d438506ea02
Contents?: true
Size: 1.77 KB
Versions: 13
Compression:
Stored size: 1.77 KB
Contents
require_dependency "apidae/application_controller" module Apidae class ProjectsController < ApplicationController before_action :set_project, only: [:edit, :update, :destroy] def index @projects = Project.all end def new session[:referrer] = request.referrer.split('?').first @project = Project.new(locales: [DEFAULT_LOCALE], versions: [DEFAULT_VERSION]) end def create if Project.find_by_apidae_id(project_params[:apidae_id]) @project = Project.find_by_apidae_id(project_params[:apidae_id]) update_project else @project = Project.new(project_params) if @project.save referrer = session.delete(:referrer) redirect_to (referrer + "?apidae_project_id=#{@project.id}"), notice: 'Le projet a bien été créé' else flash.now[:alert] = "Une erreur s'est produite lors la création du projet" render :new end end end def edit session[:referrer] = request.referrer.split('?').first end def update update_project end def destroy @project.destroy redirect_to request.referrer, notice: 'Le projet a bien été supprimé.' end private def set_project @project = Project.find(params[:id]) end def update_project if @project.update(project_params) referrer = session.delete(:referrer) redirect_to (referrer + "?apidae_project_id=#{@project.id}"), notice: 'Le projet a bien été mis à jour' else flash.now[:alert] = "Une erreur s'est produite lors la mise à jour du projet" render :edit end end def project_params params.require(:project).permit(:name, :api_key, :apidae_id, locales: [], versions: []) end end end
Version data entries
13 entries across 13 versions & 1 rubygems