]> git.openstreetmap.org Git - rails.git/commitdiff
Make notes RSS feeds work
authorTom Hughes <tom@compton.nu>
Sat, 2 Feb 2013 17:48:56 +0000 (17:48 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 2 Feb 2013 17:48:56 +0000 (17:48 +0000)
app/views/notes/_description.html.erb
config/initializers/action_view.rb [new file with mode: 0644]
lib/nominatim.rb

index 435f263c691f7f84881dcbfab11fb70b49115e8a..761b69ea2db87fc7dd0528a1188a0705243328f0 100644 (file)
@@ -1,7 +1,7 @@
 <div>
   <% description.comments.each do |comment| -%>
   <div class="note-comment" style="margin-top: 5px">
 <div>
   <% description.comments.each do |comment| -%>
   <div class="note-comment" style="margin-top: 5px">
-    <% if comment.author.nil> -%>
+    <% if comment.author.nil? -%>
     <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %></div>
     <% else -%>
     <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
     <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %></div>
     <% else -%>
     <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
diff --git a/config/initializers/action_view.rb b/config/initializers/action_view.rb
new file mode 100644 (file)
index 0000000..1789ec1
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# Make :formats work when rendering one partial from another
+#
+# Taken from https://github.com/rails/rails/pull/6626
+#
+module ActionView
+  class AbstractRenderer #:nodoc:
+    def prepend_formats(formats)
+      formats = Array(formats)
+      return if formats.empty?
+      @lookup_context.formats = formats | @lookup_context.formats
+    end
+  end
+
+  class PartialRenderer
+    def setup_with_formats(context, options, block)
+      prepend_formats(options[:formats])
+      setup_without_formats(context, options, block)
+    end
+
+    alias_method_chain :setup, :formats
+  end
+
+  class TemplateRenderer
+    def render_with_formats(context, options)
+      prepend_formats(options[:formats])
+      render_without_formats(context, options)
+    end
+
+    alias_method_chain :render, :formats
+  end
+end
index 5b1c7ac3203ca92ffdcda856ed3a47ba5a15cc01..1d2037d8d171c30badf2a07feb5b7d5ceb92eafa 100644 (file)
@@ -1,4 +1,6 @@
 module Nominatim
 module Nominatim
+  extend ActionView::Helpers::NumberHelper
+
   def self.describe_location(lat, lon, zoom = nil, language = nil)
     zoom = zoom || 14
     language = language || request.user_preferred_languages.join(',')
   def self.describe_location(lat, lon, zoom = nil, language = nil)
     zoom = zoom || 14
     language = language || request.user_preferred_languages.join(',')