Project

General

Profile

Download (1.08 KB) Statistics
| Branch: | Tag: | Revision:

root / lib / rails_fixes.rb @ b75e1935

1
# needed for gettext
2
# see http://zargony.com/2008/02/12/edge-rails-and-gettext-undefined-method-file_exists-nomethoderror
3
module ActionView
4
  class Base
5
    delegate :file_exists?, :to => :finder unless respond_to?(:file_exists?)
6
  end
7
end
8

    
9
# fix collection_select ignoring :selected option
10
# needs to bug, see http://dev.rubyonrails.org/ticket/1125
11
module ActionView::Helpers
12
  class InstanceTag
13
    def to_collection_select_tag(collection, value_method, text_method, options, html_options)
14
      html_options = html_options.stringify_keys
15
      add_default_name_and_id(html_options)
16
      value = value(object)
17
      selected_value = options.has_key?(:selected) ? options[:selected] : value
18
      content_tag(
19
        "select", add_options(options_from_collection_for_select(collection, value_method, text_method, selected_value), options, selected_value), html_options
20
      )   
21
    end
22
  end
23
end
24

    
25
class ActiveRecord::Base
26
  def human_name
27
    self.class.human_name
28
  end
29

    
30
  def self.human_name(options={})
31
    ::ActiveRecord::Base.human_attribute_table_name_for_error(self.to_s.underscore)
32
  end
33
end
34

    
(3-3/5)