Class: IndexFor::ActionBuilder
- Defined in:
- lib/index_for/builders/action_builder.rb
Instance Attribute Summary
Attributes inherited from Builder
#html_options, #object, #template
Instance Method Summary collapse
Methods inherited from Builder
#actions, #association, #attribute, #attributes, #fields_for, #initialize
Constructor Details
This class inherits a constructor from IndexFor::Builder
Instance Method Details
#action_link(action_name, options = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/index_for/builders/action_builder.rb', line 6 def action_link action_name, = {}, &block if block @template.capture(@object, &block) else object = @html_options[:namespace] ? @html_options[:namespace].clone.push(@object) : @object action_title = (translate(:"actions.#{action_name}") || action_name.to_s.humanize).html_safe = :action_link, append_class , :"action_#{action_name}", [:class] [:data] ||= {} [:data].reverse_merge!(.slice(:method, :confirm)) link_path = [:url] || case action_name when :show, :destroy @template.polymorphic_path(object) else @template.polymorphic_path(object, action: action_name) end [:data].reverse_merge!( method: :delete, confirm: translate(:"actions.confirmation")) if action_name == :destroy @template.link_to action_title, link_path, end end |