Sha256: 6e81b5172ed5f464ecc0c3085a33c2af8fcb3340ef4cbfc74692f3a747f5fbde

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module ContentsHelper
  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


  # from http://railscasts.com/episodes/196-nested-model-form-revised?view=asciicast
  # def link_to_add_fields(name, f, association)
  #   new_object = f.object.send(association).klass.new
  #   id = new_object.object_id
  #   fields = f.fields_for(association, new_object, child_index: id) do |builder|
  #     render(association.to_s.singularize + "_fields", f: builder)
  #   end
  #   link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
  # end

  def link_to_add_fields(name, f, association)
    new_object = f.object.send(association).klass.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 })
    end
    link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
common-content-0.0.2 app/helpers/contents_helper.rb
common-content-0.0.1 app/helpers/contents_helper.rb