私は現在、ブートストラップに基づいたカスタムフォームヘルパーを書いていますが、依存関係に問題があります(私は思います):
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::OutputSafetyHelper
alias :super_collection_select :collection_select
def collection_select_append(method, collection, value_method, text_method, options = {}, html_options = {})
('<div class="control-group' + has_error(object.errors[method]) + '">' +
label(method, :class => "control-label") +
'<div class="controls">' +
'<div class="input-append">' +
super_collection_select(method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options)) +
'<span class="add-on">' +
link_to(raw("<i class\"icon-white icon-ok\"></i>"), {:controller => "myController", :action => "myAction"}, :method => "post", :remote => true, :html => { :val1 => "val1", :val2 => "val2" } ) +
'</span>' +
'</div>' +
get_error_message(object.errors[method]) +
'</div>' +
'</div>').html_safe
end
end
これはエラーを返しています:
undefined local variable or method `controller' for #<..>