refactor and make i18n nicer

This commit is contained in:
John Bintz 2012-11-01 13:19:36 -04:00
parent 09fe15c446
commit 83beb92d4a
1 changed files with 7 additions and 2 deletions

View File

@ -21,7 +21,7 @@ class CocoonInput
def semantic_fields_for
builder.semantic_fields_for(method) do |fields|
if fields.object
template.render :partial => "#{method.to_s.singularize}_fields", :locals => { :f => fields }
template.render :partial => "#{singular_method}_fields", :locals => { :f => fields }
end
end
end
@ -32,7 +32,7 @@ class CocoonInput
def links
template.content_tag(:div, :class => 'links') do
template.link_to_add_association template.t('.add'), builder, method, input_html_options
template.link_to_add_association template.t(".add_#{singular_method}"), builder, method, input_html_options
end
end
@ -43,5 +43,10 @@ class CocoonInput
'data-association-insertion-method' => 'append'
)
end
private
def singular_method
@singular_method ||= method.to_s.singularize
end
end