Module: ContentsHelper

Defined in:
app/helpers/contents_helper.rb

Instance Method Summary collapse

Instance Method Details

#hateoas_uri_options(source, entity) ⇒ Object



2
3
4
5
6
# File 'app/helpers/contents_helper.rb', line 2

def hateoas_uri_options(source, entity)
  # open the source url
  # parse out the entities
  # look for <name> and <link rel='self'> and parse into [[link, name]]   
end


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/contents_helper.rb', line 11

def link_to_add_fields(name, f, association, enclosing_element = nil)
  begin
    new_object = f.object.send(association).klass.new
  rescue Exception => e
    p e
  end
  new_object ||= ::Content.const_get(association.to_s.camelize).new
  id = new_object.object_id
  fields = f.fields_for(association, new_object, child_index: id) do |builder|
    render(partial: association.to_s.singularize + "_fields", locals: { f: builder, child_index: id })
  end
  link_to(name, '#', class: "add_fields", 
            data: {id: id, fields: fields.gsub("\n", ""), enclosing: enclosing_element})
end