Class: ErpInventory::ErpApp::Organizer::AssetManagement::FacilitiesController
- Inherits:
-
ErpApp::Organizer::BaseController
- Object
- ErpApp::Organizer::BaseController
- ErpInventory::ErpApp::Organizer::AssetManagement::FacilitiesController
- Defined in:
- app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #show_summary ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 45 def create facility = Facility.new facility.description=params[:description] facility.save render :json => {:success => true, :data => facility.to_hash(:only => [:id, :description, :created_at, :updated_at])} end |
#destroy ⇒ Object
67 68 69 70 71 72 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 67 def destroy facility = Facility.find(params[:facility_id]).destroy render :json => {:success => true} end |
#edit ⇒ Object
54 55 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 54 def edit end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 7 def index offset = params[:start] || 0 limit = params[:limit] || 25 query_filter = params[:query_filter].blank? ? nil : params[:query_filter].strip factility_tbl = Facility.arel_table statement = Facility.order('created_at asc') unless query_filter.blank? statement = statement.where(factility_tbl[:description].matches(query_filter + '%')) end # Get total count of records total = statement.count # Apply limit and offset facilities = statement.offset(offset).limit(limit) render :json => {:success => true, :total => total, :facilities => facilities.collect { |facility| facility.to_hash(:only => [:id, :description, :created_at, :updated_at]) }} end |
#new ⇒ Object
42 43 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 42 def new end |
#show ⇒ Object
35 36 37 38 39 40 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 35 def show facility = Facility.find(params[:facility_id]) render :json => {:success => true, :data => facility.to_hash(:only => [:id, :description, :created_at, :updated_at])} end |
#show_summary ⇒ Object
29 30 31 32 33 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 29 def show_summary @facility = Facility.find(params[:id]) rescue nil end |
#update ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/erp_inventory/erp_app/organizer/asset_management/facilities_controller.rb', line 57 def update facility = Facility.find(params[:facility_id]) facility.description=params[:description] facility.save render :json => {:success => true, :data => facility.to_hash(:only => [:id, :description, :created_at, :updated_at])} end |