Declare api relation relations as nested resources
This commit is contained in:
parent
2a38dca0b7
commit
f696b5439e
10 changed files with 108 additions and 45 deletions
25
app/controllers/api/relations/relations_controller.rb
Normal file
25
app/controllers/api/relations/relations_controller.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Api
|
||||
module Relations
|
||||
class RelationsController < ApiController
|
||||
authorize_resource
|
||||
|
||||
before_action :set_request_formats
|
||||
|
||||
def index
|
||||
relation_ids = RelationMember.where(:member_type => "Relation", :member_id => params[:relation_id]).collect(&:relation_id).uniq
|
||||
|
||||
@relations = []
|
||||
|
||||
Relation.find(relation_ids).each do |relation|
|
||||
@relations << relation if relation.visible
|
||||
end
|
||||
|
||||
# Render the result
|
||||
respond_to do |format|
|
||||
format.xml
|
||||
format.json
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue