Hello, I allready asked about embedding an engine view from an app view
: using partials works fine.
Now, my main app needs to ask my publish engine : give me a “news”
block. This block of datas will be embedded in the site’s main page.
What are the news, how to retrieve and how to format them is a job for
the engine.
Unfortunately I really don’t know how to achieve this. What I want to do
is calling an engine controller (which retrieve the news, then render
the view accordingly) from an app view.
Embedding “black-boxed” datas from an engine in the app (or may be into
another engine view) is certainly a common need for every engines users
and I’m pretty sure there is an elegant solution I’m been missing.
To achieve this, your publish engine should supply a ‘news component’,
which you can render in your views with ‘render_component’. See the
Rails docs on components for more information…
And then comes the next (and last I hope) problem :
mysite/app/controllers/site_controller with action index
-> which render the view mysite/app/views/index.rhtml
–> which contains <%= render_component :controller =>
ArticlesController, :action => “newarticles” %>
—> which calls controller (uses_component_template_root)
MYENGINE_ROOT/app/controllers/articles_controller with action
newarticles
----> which render MYENGINE_ROOT/app/controllers/newarticles.rhtml !!!
<-- GOTCHA HERE ###
Why does it tries to find the view in this directory instead of views
directory ?
Got different behaviours today - I can use several parameters :
render_component :controller => ArticlesController, :action =>
“newarticles”
render_component :controller => “Articles”, :action => “newarticles”
And in articles_controller.rb no matter if I
render “newsarticles” or render “…/views/newsarticles”
I’ve restarted webrick between each change just in case…
But I can’t use
render_component :controller => ‘articles_controller’, :action =>
“newarticles”
Which produce an uninitialized constant ArticlesControllerController
Is opening a ticket still needed or these behaviours are the right ones
?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.