Class: Spree::Api::PropertiesController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/spree/api/properties_controller.rb', line 22
def create
authorize! :create, Property
@property = Spree::Property.new(params[:property])
if @property.save
respond_with(@property, :status => 201, :default_template => :show)
else
invalid_resource!(@property)
end
end
|
#destroy ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/spree/api/properties_controller.rb', line 41
def destroy
authorize! :delete, Property
if(@property)
@property.destroy
respond_with(@property, :status => 204)
else
invalid_resource!(@property)
end
end
|
#index ⇒ Object
8
9
10
11
12
13
|
# File 'app/controllers/spree/api/properties_controller.rb', line 8
def index
@properties = Spree::Property.
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page])
respond_with(@properties)
end
|
#new ⇒ Object
19
20
|
# File 'app/controllers/spree/api/properties_controller.rb', line 19
def new
end
|
#show ⇒ Object
15
16
17
|
# File 'app/controllers/spree/api/properties_controller.rb', line 15
def show
respond_with(@property)
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/controllers/spree/api/properties_controller.rb', line 32
def update
authorize! :update, Property
if @property && @property.update_attributes(params[:property])
respond_with(@property, :status => 200, :default_template => :show)
else
invalid_resource!(@property)
end
end
|