passing a variable to a partial

I have a chunk of rhtml that gets reused by several views in several controllers. I make partial out of it _foo and call it with

<%= render :partial =>'bar/foo' %>

# RAILS_ROOT/app/views/bar/_foo.rhtml

(note I'm not calling with a collection.) Is there a way to send a variable to the partial? the doc says i can use :locals => { :name => 'val' } but what I want to do is alias :name to another variable. I can always set some class variable @var and using that inside the partial, but I want to make it explicit what it is that I'm passing to the partial.

also, is this the way to share something among views? I'm aware of layouts but that seems to be for whole page content, rather than common snippets.

Have a look at the methods discussed in this article, http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/

As usual, you’re on the ball Greg. I was thinking about that very resource, but couldn’t remember where I saw it.

Peace,

Phillip

Have a look at the methods discussed in this article, WEBSITE.WS - Your Internet Address For Life™

-- def gw    acts_as_n00b    writes_at(www.railsdev.ws) end

As usual, you're on the ball Greg. I was thinking about that very
resource, but couldn't remember where I saw it.

Well it would be surprising if he'd forgotton something he'd written
himself :slight_smile:

Fred

Aye, and you are on the ball, too, Fred. :slight_smile:

Peace, Phillip

thank you. excellent article.

an O/T question. what is the font used in the pdf for the code portion? it's a nice fixed monospace font and I'm always on the lookout for good monospace fonts to use for coding :slight_smile: Currently I use Lucida Console but it has a problem in that commas and periods look too much alike.

Well, given that I tend to write such things at the moment I reach my epiphany about the topic, I can very easily forget what I write :slight_smile: I've been pointed to my own advice more than once :stuck_out_tongue:

That would be Monaco (default monospaced font on a Mac)

-- gw