<% unless params[:context] == :gallery -%> question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

<% unless params[:context] == :gallery -%> question

charlie bowman
I have a template that is called by two different methods.  I only want
part of it too show up when it is called from one of the methods.  It
always shows up for me.  Can someone help to point out my error?  Below
is the method that should keep part of the tempate from printing, and
the relevent part of the template.

method:
  def gallery
    @product_pages,@products = paginate(:products, :per_page  => 12,
:conditions => "sold != 'current'")
    render( :template   => "store/index",
            :params     =>  { :context  => :gallery})
  end

template:
            <% unless params[:context] == :gallery -%>
            <span id="product_price"><%= @products[0].price %></span><br
/>
            <span id="cart_link"> <%= link_to 'Add to Cart',
                    {:action => 'add_to_cart', :id => product },
                    :class => 'addtocart' %><br/>
            </span>
            <% end -%>

--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: <% unless params[:context] == :gallery -%> question

Francois GORET
Hello,

in the controller, try:
@context = :gallery
render :template => "store/index"

and in the template
<% unless @context == :gallery -%>

There's a :locals option for render, but it seems that it works only for
rendering partials.

On Monday 19 December 2005 09:29, charlie bowman wrote:

> I have a template that is called by two different methods.  I only want
> part of it too show up when it is called from one of the methods.  It
> always shows up for me.  Can someone help to point out my error?  Below
> is the method that should keep part of the tempate from printing, and
> the relevent part of the template.
>
> method:
>   def gallery
>     @product_pages,@products = paginate(:products, :per_page  => 12,
>
> :conditions => "sold != 'current'")
>
>     render( :template   => "store/index",
>
>             :params     =>  { :context  => :gallery})
>
>   end
>
> template:
>             <% unless params[:context] == :gallery -%>
>             <span id="product_price"><%= @products[0].price %></span><br
> />
>             <span id="cart_link"> <%= link_to 'Add to Cart',
>                     {:action => 'add_to_cart', :id => product },
>
>                     :class => 'addtocart' %><br/>
>
>             </span>
>             <% end -%>
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails