##// END OF EJS Templates
remove Rails2 named_scope wrapper from config/initializers/10-patches.rb...
Toshi MARUYAMA -
r9357:6f8d7d6e768a
parent child
Show More
@@ -1,94 +1,90
1 1 require 'active_record'
2 2
3 3 module ActiveRecord
4 4 class Base
5 5 include Redmine::I18n
6 def self.named_scope(*args)
7 scope(*args)
8 end
9
10 6 # Translate attribute names for validation errors display
11 7 def self.human_attribute_name(attr, *args)
12 8 l("field_#{attr.to_s.gsub(/_id$/, '')}", :default => attr)
13 9 end
14 10 end
15 11 end
16 12
17 13 module ActionView
18 14 module Helpers
19 15 module DateHelper
20 16 # distance_of_time_in_words breaks when difference is greater than 30 years
21 17 def distance_of_date_in_words(from_date, to_date = 0, options = {})
22 18 from_date = from_date.to_date if from_date.respond_to?(:to_date)
23 19 to_date = to_date.to_date if to_date.respond_to?(:to_date)
24 20 distance_in_days = (to_date - from_date).abs
25 21
26 22 I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
27 23 case distance_in_days
28 24 when 0..60 then locale.t :x_days, :count => distance_in_days.round
29 25 when 61..720 then locale.t :about_x_months, :count => (distance_in_days / 30).round
30 26 else locale.t :over_x_years, :count => (distance_in_days / 365).floor
31 27 end
32 28 end
33 29 end
34 30 end
35 31 end
36 32
37 33 class Resolver
38 34 def find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[])
39 35 cached(key, [name, prefix, partial], details, locals) do
40 36 if details[:formats] & [:xml, :json]
41 37 details = details.dup
42 38 details[:formats] = details[:formats].dup + [:api]
43 39 end
44 40 find_templates(name, prefix, partial, details)
45 41 end
46 42 end
47 43 end
48 44 end
49 45
50 46 ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
51 47
52 48 require 'mail'
53 49
54 50 module DeliveryMethods
55 51 class AsyncSMTP < ::Mail::SMTP
56 52 def deliver!(*args)
57 53 Thread.start do
58 54 super *args
59 55 end
60 56 end
61 57 end
62 58
63 59 class AsyncSendmail < ::Mail::Sendmail
64 60 def deliver!(*args)
65 61 Thread.start do
66 62 super *args
67 63 end
68 64 end
69 65 end
70 66
71 67 class TmpFile
72 68 def initialize(*args); end
73 69
74 70 def deliver!(mail)
75 71 dest_dir = File.join(Rails.root, 'tmp', 'emails')
76 72 Dir.mkdir(dest_dir) unless File.directory?(dest_dir)
77 73 File.open(File.join(dest_dir, mail.message_id.gsub(/[<>]/, '') + '.eml'), 'wb') {|f| f.write(mail.encoded) }
78 74 end
79 75 end
80 76 end
81 77
82 78 ActionMailer::Base.add_delivery_method :async_smtp, DeliveryMethods::AsyncSMTP
83 79 ActionMailer::Base.add_delivery_method :async_sendmail, DeliveryMethods::AsyncSendmail
84 80 ActionMailer::Base.add_delivery_method :tmp_file, DeliveryMethods::TmpFile
85 81
86 82 module ActionController
87 83 module MimeResponds
88 84 class Collector
89 85 def api(&block)
90 86 any(:xml, :json, &block)
91 87 end
92 88 end
93 89 end
94 90 end
General Comments 0
You need to be logged in to leave comments. Login now