in rails I would have a controller for widgets with an index, show, and crud methods.
the index controller would have a simple
@widgets = Widget.all
respond_to do |format|
format.html
format.json {render :json => @widgets}
then, on my home page, or any page in my main apps folder, I could say
<% @widgets.each do |w| %>
<p><%= w.name %></p>
<%end%>
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
uninitialized constant Refinery::PagesController::Widget
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?
Example: app.main.views.index.html.erb
<h1> this is my home page. We sell all sorts of stuff including: </h1>
<% @widgets.each do |w| %>
<p><%= w.name %></p>
<%end%>
<% @gadgets.each do |g| %>
<p><%= g.name %></p>
<%end%>
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.
EDIT This is the home action in my pages_controller.rb located in app>controllers>refinery directory:
def home
@widgets = Widget.all
respond_to do |format|
format.html
format.json { render json: @widgets}
end
#render_with_templates?
end