Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to render collection from home page in rails 3.12
    primarykey
    data
    text
    <p>in rails I would have a controller for widgets with an index, show, and crud methods.<br> the index controller would have a simple </p> <pre><code>@widgets = Widget.all respond_to do |format| format.html format.json {render :json =&gt; @widgets} </code></pre> <p>then, on my home page, or any page in my main apps folder, I could say</p> <pre><code>&lt;% @widgets.each do |w| %&gt; &lt;p&gt;&lt;%= w.name %&gt;&lt;/p&gt; &lt;%end%&gt; </code></pre> <p>With Refinery I have a widgets engine, and the controllers in those engines don't have the standard index, show, and crud methods. If I override the home action in refinery pages_controller.rb with the code above I get the error </p> <p>uninitialized constant Refinery::PagesController::Widget</p> <p>My question is: how do I refer to classes in my refinery engines such that I can include them in my views from my main rails app?</p> <p>Example: app.main.views.index.html.erb</p> <pre><code> &lt;h1&gt; this is my home page. We sell all sorts of stuff including: &lt;/h1&gt; &lt;% @widgets.each do |w| %&gt; &lt;p&gt;&lt;%= w.name %&gt;&lt;/p&gt; &lt;%end%&gt; &lt;% @gadgets.each do |g| %&gt; &lt;p&gt;&lt;%= g.name %&gt;&lt;/p&gt; &lt;%end%&gt; </code></pre> <p>where both widgets and gadgets are refinery engines. I have a vanilla rails app that does this very thing and it works but I would like to know how to do it in refinery, because figuring this out will open the world to me. Could someone please advise or point to some documentation I might have overlooked that will help out.</p> <p><strong>EDIT</strong> This is the home action in my pages_controller.rb located in app>controllers>refinery directory:</p> <pre><code> def home @widgets = Widget.all respond_to do |format| format.html format.json { render json: @widgets} end #render_with_templates? end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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