dryml_generators/rapid/pages.dryml.erb in hobo-0.8 vs dryml_generators/rapid/pages.dryml.erb in hobo-0.8.1

- old
+ new

@@ -73,13 +73,15 @@ main_content = model.primary_content_attribute show_fields = standard_fields(:belongs_to).*.to_s - [model.name_attribute, main_content, creator, back_link, *boolean_fields].*.to_s collection = model.dependent_collections.sort_by(&:to_s).first if collection collection_class = model.reflections[collection].klass - owner = model.reverse_reflection(collection).name - add_link = collection &&linkable?(collection_class, :"new_for_#{owner}") - add_form = !add_link && linkable?(collection_class, :"create_for_#{owner}", :method => :post) + owner = model.reverse_reflection(collection)._?.name + if owner + add_link = collection &&linkable?(collection_class, :"new_for_#{owner}") + add_form = !add_link && linkable?(collection_class, :"create_for_#{owner}", :method => :post) + end end -%> <def tag="show-page" for="<%= model.name %>"> <page merge title="<%= model_name :title %>"> @@ -108,11 +110,11 @@ <% end -%> </header> <section param="content-body"> <% if main_content -%> - <view:<%= main_content %>/> + <view:<%= main_content %> param="primary-content"/> <% end -%> <% if show_fields.any? -%> <field-list fields="<%= show_fields * ', ' %>" param/> <% end -%> <% if collection -%> @@ -124,16 +126,16 @@ <% else -%> <collection:<%= collection %> param/> <% end -%> <% if add_link -%> - <a:<%= collection %> action="new" if="&can_create?" param="new-link">New <%= collection.to_s.singularize.titleize %></a> + <a:<%= collection %> action="new" if="&can_create?(@<%= model_name.underscore %>.<%= collection %>)" param="new-link">New <%= collection.to_s.singularize.titleize %></a> <% elsif add_form -%> <section param="add-to-collection" if="&can_create?(@<%= model_name.underscore %>.<%= collection %>)"> <h3 param="add-form-heading">Add <%= a_or_an collection.to_s.singularize.titleize %></h3> - <form with="&@<%= collection_class.name.underscore %> || @<%= model_name.underscore %>.<%= collection %>.new" owner="<%= owner %>" method="post" without-or-cancel param> + <form with="&@<%= collection_class.name.underscore %> || @<%= model_name.underscore %>.<%= collection %>.new" owner="<%= owner %>" method="post" without-cancel param> <field-list: skip="<%= owner %>"/> <submit: label="Add"/> </form> </section> <% end -%> @@ -261,10 +263,10 @@ <% model::Lifecycle.transitions.where.publishable?.*.name.each do |transition| -%> <def tag="<%= transition.dasherize %>-page" polymorphic/> <def tag="<%= transition.dasherize %>-page" for="<%= model.name %>"> <page title="<%= transition.titleize %>" merge> - <body: class="lifecycle-transition-page #{transition.dasherize}-page" param/> + <body: class="lifecycle-transition-page <%= transition.dasherize -%>-page" param/> <content:> <header param="content-header"> <h2 param="heading"><%= transition.titleize %></h2> </header>