]> git.openstreetmap.org Git - rails.git/commitdiff
Rework to ensure views are named after the controller method name
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 26 Jun 2019 10:52:21 +0000 (12:52 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 26 Jun 2019 11:45:40 +0000 (13:45 +0200)
app/controllers/api/traces_controller.rb
app/controllers/api/users_controller.rb
app/views/api/traces/show.builder [new file with mode: 0644]
app/views/api/users/gpx_files.builder [moved from app/views/api/traces/trace.builder with 53% similarity]

index fd43a1d44500681ee874c8faf15e2bfe07aef6c4..8979704a71802167af2b374ea8f173259bd36215 100644 (file)
@@ -16,14 +16,9 @@ module Api
     around_action :api_call_handle_error
 
     def show
-      trace = Trace.visible.find(params[:id])
+      @trace = Trace.visible.find(params[:id])
 
-      if trace.public? || trace.user == current_user
-        @traces = [trace]
-        render "trace"
-      else
-        head :forbidden
-      end
+      head :forbidden unless @trace.public? || @trace.user == current_user
     end
 
     def update
index e6922e0a078da5b390a452b017eb145422daa959..43d5ec90883752b3212a9dfb73e32e5633b53de9 100644 (file)
@@ -38,7 +38,7 @@ module Api
 
     def gpx_files
       @traces = current_user.traces.reload
-      render "api/traces/trace", :content_type => "application/xml"
+      render :content_type => "application/xml"
     end
 
     private
diff --git a/app/views/api/traces/show.builder b/app/views/api/traces/show.builder
new file mode 100644 (file)
index 0000000..f4a4e4d
--- /dev/null
@@ -0,0 +1,5 @@
+xml.instruct! :xml, :version => "1.0"
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+  osm << render(@trace)
+end
similarity index 53%
rename from app/views/api/traces/trace.builder
rename to app/views/api/users/gpx_files.builder
index 1e278f770e630060e63803dbcb4f895dae5b710d..d5287ffbd6d2b1283ae8259dd6f0732ea1ce739c 100644 (file)
@@ -1,9 +1,7 @@
 xml.instruct! :xml, :version => "1.0"
 
-# basic attributes
-
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
   @traces.each do |trace|
-    osm << render(:partial => "api/traces/trace.builder", :locals => { :trace => trace })
+    osm << render(:partial => "api/traces/trace", :locals => { :trace => trace })
   end
 end