You asked for it.
# app/controllers/tags_controller
.rb
def index
params[:sort] ||= "url_title"
@direction = !params[:x] ? "ASC" : "DESC"
@tags =
Tag.find(:all, :order => "#{params[:sort]} #{@direction}")
render_common_index
end
# render_common_index => render :template => "common/index"
# app/views/common/index.haml
= render :partial => "documents/drafts" if @drafts and !@
drafts.empty?
- if collection.to_a.size > 5
= render :partial => "common/commands"
= index_feedback
- if @category
%p#scoped= "<label>Category:</label> #{link_to @category.title_html
, {:action => :index}, :class => :category, :title => "Remove category restriction and view all #{trollers}"}"
- if @tag
%p#scoped= "<label>Tag:</label> #{link_to @tag.title_html
, {:action => :index}, :class => :tag, :title => "Remove tag restriction and view all #{trollers}"}"
= render_common_table
= render :partial => "common/commands"
# trollers is merely shorthand [defined in a helper] for
controller.controller_name.pluralize
# render_common_table => render :template => "common/table"
# app/views/common/table
- if action == "search" and !collection.empty?
%p#results= pluralize(
collection.size, "Result") + " for " + content_tag(:span, params[:q])
%table
- if collection.empty?
- if action == "search"
%tr
%td.empty
= "Sorry, we were unable to find any #{trollers} which match your
search terms: <span>#{params[:q]}</span>"
- if @excluded
%br/
= "These terms were excluded from your search: <span>#{@excluded.join(" ")}</span>"
%br/
Please try again, making sure your terms each have at least four letters.
- else
%tr
%td.empty= "You currently have no " + published? + trollers
- else
%thead
= render :partial => "#{troller}_headers"
%tbody
= render :partial => troller, :collection => collection
- if collection.respond_to?(:page_count) and collection.page_count > 1
%tr.pagination
%td{:colspan => troller == "entry" ? 7 : 6}= page_links
# troller is the singular of that trollers earlier.
# collection => controller.instance_variable_get("@#{trollers}")
# That render :partial => troller, :collection => collection is actually...
# render :partial => "tag", :collection => @tags
# which is where the tag reference screws up, I think.
All
of this actuall comes out right. The _problem_ is that ones it compiles
this the first go-round, in my application.haml layout
!!! Strict
%html
%head
%title= "Oyster" + subtitle
= javascript_include_tag :defaults
= stylesheet_link_tag("oyster").downcase
That stylesheet_link_tag("oyster").downcase
returns a member of the @tags array. There's a call to the Rails method
tag in there somewhere and because the page has been compiled that
first time tag is still showing up from the render :partial =>
"tag", :collection => @tags which [I assume] is basically a @
tags.each do |tag| and I've seen where that tag from the loop can stay
in or out of "scope" oddly before.
Does that clear it up? [Clear as mud, right?]
RSL