Sha256: cf735fbdc11e1a79f022fff3b8f5c0f9a66bd3f95effc6dfd2147ac24d1de216

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module ActionView
  module Helpers
    module FormHelper
      def label_with_ja(object_name, method, text = nil, options = {})
        if text.nil?
          text = I18n.t(method,              :default => method, :scope => [:activerecord, :attributes, object_name])
          text = I18n.t(method,              :default => method, :scope => [:activerecord, :attributes, "commons"])   if text.include?("translation missing:")
          text = I18n.t(method.to_s + "_id", :default => method, :scope => [:activerecord, :attributes, object_name]) if text.include?("translation missing:")
        end
        label_without_ja(object_name, method, text, options)
      end
      alias_method_chain :label, :ja  #:nodoc:
    end

    module DateHelper
      def date_select_with_options(object_name, method, options = {}, html_options = {})
        begin
          object = self.instance_variable_get("@#{object_name}")
          value = object.send(method)
          value = I18n.l(value)
        rescue
          value = nil
        end
        value = "" if value.blank?
        options.merge!(:class     => 'ymd',
                       :size      => 14,
                       :maxlength => 10,
                       :readonly  => true,
                       :value     => value)
        text_field(object_name, method, options)
      end
      alias_method_chain :date_select, :options  #:nodoc:
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ava_rails_generator-0.0.3 templates/action_view_helper.rb
ava_rails_generator-0.0.2 templates/action_view_helper.rb