Class: Admin::FeaturesController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::FeaturesController
- Includes:
- FeatureGetterHelper
- Defined in:
- app/controllers/admin/features_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/admin/features_controller.rb', line 10 def create @features_fields = Feature.non_common_fields.map{|f| f[:name]} params_for_insert = Hash[params.select{|key, value| @features_fields.include?(key)}.map{|key, value| [key, value = value.blank?? nil : value]}] @new_feature = CartoDB::Connection.insert_row Cartoset::Config['features_table'], params_for_insert redirect_to admin_feature_path(@new_feature.cartodb_id) end |
#destroy ⇒ Object
34 35 36 37 |
# File 'app/controllers/admin/features_controller.rb', line 34 def destroy CartoDB::Connection.delete_row Cartoset::Config['features_table'], params[:id] redirect_to admin_path end |
#new ⇒ Object
30 31 32 |
# File 'app/controllers/admin/features_controller.rb', line 30 def new @features_fields = Feature.non_common_fields end |
#show ⇒ Object
6 7 8 |
# File 'app/controllers/admin/features_controller.rb', line 6 def show @features_fields = Feature.non_common_fields end |
#update ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/admin/features_controller.rb', line 20 def update @features_fields = Feature.non_common_fields.map{|f| f[:name]} params_for_update = params.select{|key, value| @features_fields.include?(key)} CartoDB::Connection.update_row Cartoset::Config['features_table'], params[:id], params_for_update redirect_to admin_feature_path(params[:id]) end |