Using partials with Markaby

I’m trying to use a partial from within Markaby. I haven’t been able to
figure out how to access a parameter passed into the partial. Here’s the
code I’m using:

h1 “Create a new note”

if @note
render :partial => ‘form/errors’, :record => @note
end

(that snippet, as well as the partial is stolen shamelessly from
Restolog
(thought converted to Markaby), which is a nice example of a REST-ful
rails
app)

here’s the partial, in form/_errors.mab:
unless record.nil? or record.errors.empty?
div :class => “message-error” do
p “The #{record.class.to_s.downcase} could not be saved:”

ul do
record.errors.full_messages.each do |m|
li m.gsub(/ id /, ’ ')
end
end
end
end

The error I get is this:

notes/vendor/plugins/markaby/lib/markaby/builder.rb:203:in
method_missing': no such method record’

Anyone know what I’m missing here? I suspect that there’s a special way
to
access parameters in partials for Markaby, but I haven’t been able to
figure
out what it is.


Larry W.
http://www.approachingnormal.com
http://www.welcometoparenthood.com

Try putting parens around everything after “render”

On 9/10/06, Jamie Orchard-Hays [email protected] wrote:

Try putting parens around everything after “render”

Nope, no dice. Thanks for the suggestion though.


Larry W.
http://www.approachingnormal.com
http://www.welcometoparenthood.com

try passing a hash:

render({:partial => ‘form/errors’, :record => @note})

On 9/10/06, Larry W. [email protected] wrote:

Larry,

Third example under “Rendering partials”

HTH

John W Higgins
[email protected]

On 9/10/06, Jamie Orchard-Hays [email protected] wrote:

try passing a hash:

render({:partial => ‘form/errors’, :record => @note})

Still no, unfortunately.

Larry W.
http://www.approachingnormal.com
http://www.welcometoparenthood.com

On 9/10/06, John H. [email protected] wrote:

[email protected]

That did the trick. Thanks!


Larry W.
http://www.approachingnormal.com
http://www.welcometoparenthood.com

On 9/10/06, Larry W. [email protected] wrote:

John W Higgins
[email protected]

That did the trick. Thanks!

Why not:

render :partial => ‘form/errors’, :locals => {:record => @note }

?

-ryan

That’s what the third example shows.

Hey Larry, I’m curious about your general experiences and impressions
of using Markaby instead of ERb.

Thanks,

Jamie

On 9/11/06, Jamie Orchard-Hays [email protected] wrote:

Hey Larry, I’m curious about your general experiences and impressions
of using Markaby instead of ERb.

Thanks,

Jamie

I like it. General impressions are that it’s cleaner than ERB. I’m not
working with a designer, though. If I were, I might use ERB instead as
it
seems like that would be easier for a designer to work with.

My only frustration is the lack of documentation, particularly around
things
that work differently than ERB (such as this partial thing).

Other than that, I like it better than ERB. It certainly means less
angle-bracket typing, which is nice.


Larry W.
http://www.approachingnormal.com
http://www.welcometoparenthood.com

what about:

render_partial(‘form/errors’, @note)

if that fails, try:
helpers.render_partial(‘form/errors’, @note)