Sha256: 96d59fed4406919e9cc9bdbcf28e5e0271ebada8908ff2f797525c20e5daae6f
Contents?: true
Size: 1.82 KB
Versions: 22
Compression:
Stored size: 1.82 KB
Contents
require_dependency "educode_sales/application_controller" module EducodeSales class PlacesController < ApplicationController def index respond_to do |format| authorize! :read, Place format.html do end format.json do @places = Place.page(params[:page]).per(params[:limit]) @stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id) end end end def new # gon.area_ids = @place.area_ids gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'}) render layout: false end def edit @place = Place.find(params[:id]) gon.area_ids = @place.area_ids gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'}) render layout: false end def create place = @current_admin.places.new(name: params[:name]) commons = [] params[:area_ids].each do |d| commons << Common.find(d) end place.areas = commons if place.save render_success else render_failure place end end def update place = Place.find(params[:id]) place.assign_attributes(name: params[:name]) commons = [] params[:area_ids].each do |d| commons << Common.find(d) end place.areas = commons if place.save render_success else render_failure place end end def destroy place = Place.find(params[:id]) place.destroy render_success rescue ActiveRecord::DeleteRestrictionError => e render_failure '渠道下已有关联数据产生,暂不能删除' end end end
Version data entries
22 entries across 22 versions & 1 rubygems