lib/ransack/helpers/form_builder.rb in ransack-0.1.0 vs lib/ransack/helpers/form_builder.rb in ransack-0.2.0
- old
+ new
@@ -9,19 +9,25 @@
i18n = options[:i18n] || {}
text ||= object.translate(method, i18n.reverse_merge(:include_associations => true)) if object.respond_to? :translate
super(method, text, options, &block)
end
+ def submit(value=nil, options={})
+ value, options = nil, value if value.is_a?(Hash)
+ value ||= Translate.word(:search).titleize
+ super(value, options)
+ end
+
def attribute_select(options = {}, html_options = {})
raise ArgumentError, "attribute_select must be called inside a search FormBuilder!" unless object.respond_to?(:context)
options[:include_blank] = true unless options.has_key?(:include_blank)
bases = [''] + association_array(options[:associations])
if bases.size > 1
collection = bases.map do |base|
[
Translate.association(base, :context => object.context),
- object.context.searchable_columns(base).map do |c|
+ object.context.searchable_attributes(base).map do |c|
[
attr_from_base_and_column(base, c),
Translate.attribute(attr_from_base_and_column(base, c), :context => object.context)
]
end
@@ -30,11 +36,11 @@
@template.grouped_collection_select(
@object_name, :name, collection, :last, :first, :first, :last,
objectify_options(options), @default_options.merge(html_options)
)
else
- collection = object.context.searchable_columns(bases.first).map do |c|
+ collection = object.context.searchable_attributes(bases.first).map do |c|
[
attr_from_base_and_column(bases.first, c),
Translate.attribute(attr_from_base_and_column(bases.first, c), :context => object.context)
]
end
@@ -51,11 +57,11 @@
bases = [''] + association_array(options[:associations])
if bases.any?
collection = bases.map do |base|
[
Translate.association(base, :context => object.context),
- object.context.searchable_columns(base).map do |c|
+ object.context.searchable_attributes(base).map do |c|
[
attr_from_base_and_column(base, c),
Translate.attribute(attr_from_base_and_column(base, c), :context => object.context)
]
end
@@ -67,10 +73,10 @@
) + @template.collection_select(
@object_name, :dir, [['asc', object.translate('asc')], ['desc', object.translate('desc')]], :first, :last,
objectify_options(options), @default_options.merge(html_options)
)
else
- collection = object.context.searchable_columns(bases.first).map do |c|
+ collection = object.context.searchable_attributes(bases.first).map do |c|
[
attr_from_base_and_column(bases.first, c),
Translate.attribute(attr_from_base_and_column(bases.first, c), :context => object.context)
]
end
\ No newline at end of file