[rspec-users] locals in partials

David Chelimsky dchelimsky at gmail.com
Sun Oct 14 09:57:58 EDT 2007


On 10/12/07, Hans de Graaff <hans at degraaff.org> wrote:
> On Fri, 2007-10-12 at 12:47 -0400, Jonathan Linowes wrote:
> > that works for you?
> > I'm basically doing the same thing but the
> >
> >    render "/pages/_page_menu.html.erb", :locals => { :pages => @foo }
>
> render :partial => 'pages/page_menu', :locals => {:pages => @foo}
>
> Note the :partial.

Yes - that's correct. The render method in view specs delegates to
rails' render method, but allows you to skip the :template key in the
hash as a convenience:

render '/path/to/template'

If you don't specify what '/path/to/template' represents, it is passed
like this:

controller.render :template => '/path/to/template'

So if you add additional pairs to the hash, they just get passed to
AC::Base, which only deals with :locals, :object and :collection if
you specify that you're using a partial.

Cheers,
David

>
> Kind regards,
>
> Hans
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>


More information about the rspec-users mailing list