<% flash.each do |key, value| %>
<%= value %>
<% end %> <% ul_needed = true %> <% if not defined?(parent_class) %> <% # we didn't come here via _show.html.erb %> <% if @parent_class.nil? %> <% # the controller didn't give us a parent_class, this means we are here for the 'first' time %> <% # we have to rely on the @Klass set in the controller %> <% update_span = @Klass.to_s.pluralize.downcase + '_list' %> <% human_readable_class = @Klass.to_s.humanize.downcase %> <% path_to_new = "new_#{@Klass.to_s.singularize.underscore}_path" %> <% parent_class = nil %> <% parent_id = nil %> <% objects = @objects %> <% model_name = @Klass.to_s %> <% else %> <% # the controller gave us an @parent_class, so ... %> <% attribute = @Klass.to_s.underscore.pluralize %> <% update_span = "#{@parent_class.to_s.underscore}_#{@parent_id}_#{attribute}_list" -%> <% human_readable_class= attribute.to_s.singularize.humanize.downcase %> <% path_to_new='new_' + attribute.to_s.underscore.singularize + '_path' %> <% parent_class=@parent_class.constantize %> <% parent_id=@parent_id %> <% objects = @objects %> <% ul_needed = false unless @ul_needed %> <% model_name = attribute.to_s.singularize.camelcase %> <% end %> <% else %> <% # here we come from _show %> <% update_span = "#{parent_class.to_s.underscore}_#{parent_id}_#{attribute}_list" -%> <% human_readable_class = attribute.to_s.singularize.humanize.downcase %> <% path_to_new='new_' + attribute.to_s.singularize + '_path' %> <% conditions = [ "#{parent_class.name.foreign_key} = ?", parent_id ] %> <% model_name = attribute.to_s.singularize.camelcase %> <% if cancan_enabled? %> <% objects = parent_class.find(parent_id).send(attribute).accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 5, :conditions => conditions %> <% else %> <% objects = parent_class.find(parent_id).send(attribute).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 5, :conditions => conditions %> <% end %> <% end %> <% if ul_needed %> <% end %>