Sha256: 276d34c5ca5bbcd476d6435d9c931752bf7b7002cff006bbf48774bf17f3ee59
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
require 'nitro/scaffold' module Nitro::Scaffolding # A collection of scaffolding helper for Og relations. module Og private # Scaffold the relations of an Og managed object. def scaffold_relations(obj) end # Scaffold a +belongs_to+ relation. def belongs_to_editor(obj, rel, options) entities = rel.target_class.all labels = entities.map { |e| e.to_s } values = entities.map { |e| e.oid } element( label(rel.name), %{ <select id="#{rel.name}" name="#{rel.name}"> #{options(:labels => labels, :values => values, :selected => 1)} </select> } ) end # Scaffold a +has_many+ relation. def has_many_editor(obj, rel, options) entities = obj.send(rel.target_plural_name) unless entities.empty? str = entities.inject('') do |acc, e| acc << "<tr><td>#{e.to_edit_link(@base)}</td></tr>" end str = "<table>#{str}</table>" else str = 'No entities found.<br /><br />' end element( label(rel.name) + ' <a href="#">Add</a>', %{ #{str} } ) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.23.0 | lib/nitro/scaffold/relations.rb |
nitro-0.24.0 | lib/nitro/scaffold/relations.rb |
nitro-0.25.0 | lib/nitro/scaffold/relations.rb |
nitro-0.26.0 | lib/nitro/scaffold/relations.rb |