Class: AttachinaryInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
lib/attachinary/simple_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, attribute_name, column, input_type, options = {}) ⇒ AttachinaryInput

Returns a new instance of AttachinaryInput.


4
5
6
7
8
9
# File 'lib/attachinary/simple_form.rb', line 4

def initialize(builder, attribute_name, column, input_type, options = {})
  @attachinary_options = builder.object.send("#{attribute_name.to_s.singularize}_options")
  attribute_name = @attachinary_options[:field_name]

  super builder, attribute_name, column, input_type, options
end

Instance Attribute Details

#attachinary_optionsObject (readonly)

Returns the value of attribute attachinary_options


2
3
4
# File 'lib/attachinary/simple_form.rb', line 2

def attachinary_options
  @attachinary_options
end

Instance Method Details

#inputObject


11
12
13
14
15
16
17
# File 'lib/attachinary/simple_form.rb', line 11

def input
  name = "#{@builder.object_name}[#{attribute_name}]"
  value = object.send(attribute_name)

  template.attachinary_file_field_tag name, value,
    { html: input_html_options, attachinary: attachinary_options }
end