2015-09-20 26 views

回答

1

你應該lib/simple_form/inputs/base.rb添加代碼,代碼應該是這樣的,以確保它可以自動加載

module SimpleForm 
    module Inputs 
    class Base 
     def input_html_options 
     @input_html_options... 
     end 
    end 
    end 
end 

config/initializers/simple_form_ext.rb使用class_eval這樣

SimpleForm::Inputs::Base.class_eval do 
    def input_html_options 
    @input_html_options[:'custom-attr'] = "#{object_name}.#{attribute_name}" 
    @input_html_options 
    end 
end 
+0

謝謝!有效。 – pickhunter

相關問題