app/controllers/spree/api/v1/properties_controller.rb in spree_api-3.3.6 vs app/controllers/spree/api/v1/properties_controller.rb in spree_api-3.4.0.rc1
- old
+ new
@@ -1,31 +1,29 @@
module Spree
module Api
module V1
class PropertiesController < Spree::Api::BaseController
-
before_action :find_property, only: [:show, :update, :destroy]
def index
@properties = Spree::Property.accessible_by(current_ability, :read)
- if params[:ids]
- @properties = @properties.where(id: params[:ids].split(",").flatten)
- else
- @properties = @properties.ransack(params[:q]).result
- end
+ @properties = if params[:ids]
+ @properties.where(id: params[:ids].split(',').flatten)
+ else
+ @properties.ransack(params[:q]).result
+ end
@properties = @properties.page(params[:page]).per(params[:per_page])
respond_with(@properties)
end
def show
respond_with(@property)
end
- def new
- end
+ def new; end
def create
authorize! :create, Property
@property = Spree::Property.new(property_params)
if @property.save
@@ -55,18 +53,18 @@
end
end
private
- def find_property
- @property = Spree::Property.accessible_by(current_ability, :read).find(params[:id])
- rescue ActiveRecord::RecordNotFound
- @property = Spree::Property.accessible_by(current_ability, :read).find_by!(name: params[:id])
- end
+ def find_property
+ @property = Spree::Property.accessible_by(current_ability, :read).find(params[:id])
+ rescue ActiveRecord::RecordNotFound
+ @property = Spree::Property.accessible_by(current_ability, :read).find_by!(name: params[:id])
+ end
- def property_params
- params.require(:property).permit(permitted_property_attributes)
- end
+ def property_params
+ params.require(:property).permit(permitted_property_attributes)
+ end
end
end
end
end