Sha256: 8329b97107e1b3735e409a965eb530a88575ef0e5516e26456bace3767b12d32
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 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[:per_page]) @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]) # place = Place.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 # id = @current_admin.id 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
educode_sales-0.1.2 | app/controllers/educode_sales/places_controller.rb |
educode_sales-0.1.1 | app/controllers/educode_sales/places_controller.rb |