0

我有这样的东西:f.collection_select with options

我需要修改该 collection_select 的标准行为(我需要在那里添加一些选项)

我应该在哪里做?

我认为这段代码不起作用,但你会理解这个想法

def collection_select(method, collection, value_method, text_method, options = {}, html_options = {}) 
  if options[:create_div] 
    return '<div>' + @template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)) + '</div>'
  end 
  @template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options))
end
4

1 回答 1

0

您应该将其包装为助手。您可以使用app/helpers/application_helper.rb

于 2011-08-30T07:45:11.260 回答