I need to render another controller action <%= render "controller/index" %>
and i get this error
Missing partial controller/index with {:formats=>[:html], :locale=>[:en, :en], :handlers=>[:rjs, :rhtml, :rxml, :erb, :builder]} in view paths "/path_to/app/views"
how can i render another controller action into a view but without sending an redirect to the client ? I've tried
<%=render :action => "index", :controller=>"controller" %>
but it seems that is not working.
If you do not want just to render the
view
of the other controller (/model), but calling theaction
(method), think more the ruby way of life - put this method(s) into amodule
and include it in the controllers you need it.I think its less 'spooky' then somehow touching an other controller.
From Rails Guides page:
So in short you can't render another action, you can only render another template. You could get the shared code and move it to a method in application controller. You could also try something along this lines if you really can't structure your code in some other way:
This works well for me :
then, call by
basically it hacks the other class and overwrites its "params" method and return
If you are using Rails 4:
Try to render template:
Or file:
And I believe you should render it through controller, as far as it is more convenient: