Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're redirecting to <code>clothes_path</code> (<code>redirect_to clothes_path</code>) and it seems you have <code>ClothController</code>. This controller should contain <code>index</code> method to render index page. Assign <code>current_cart</code> to <code>@cart</code> there:</p> <pre><code>class ClothController &lt; ApplicationController def index @cart = current_cart end ... end </code></pre> <hr> <p><strong>UPDATE</strong></p> <p>To make <code>@cart</code> available in all views of <code>Cloth</code> controller there is a method <code>before_filter</code> where you can set <code>@cart</code> variable. You can add this definitions in your required controllers. For more details - <a href="http://guides.rubyonrails.org/action_controller_overview.html#filters" rel="nofollow">http://guides.rubyonrails.org/action_controller_overview.html#filters</a></p> <pre><code>class ClothController &lt; ApplicationController before_filter :set_current_cart def index end ... private def set_current_cart @cart = current_cart end end </code></pre> <p><code>current_cart</code> method should be implemented as helper to be available in all controllers. (<a href="http://guides.rubyonrails.org/form_helpers.html" rel="nofollow">http://guides.rubyonrails.org/form_helpers.html</a>)</p> <hr> <p><strong>UPDATE 2</strong></p> <p>Implement a helper in <code>/app/helpers/cart_helper.rb</code>:</p> <pre><code>module CartHelper def current_cart # Your current cart method code end end </code></pre> <p>And include it into required controllers. <code>current_cart</code> method will be available in all views of controllers which contain <code>CartHelper</code>.</p> <pre><code>class ClothController &lt; ApplicationController include CartHelper ... end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload