On Tue, Jan 3, 2012 at 4:44 PM, bryan [email protected] wrote:
request or an Iframe but currently I would like it to execute in one
single request.
To retrieve the rendered data from my second method would I have to
do it as a HTTP GET? or is there some other Rails way.
If there is some other Rails way how should I structure it so I can
pass in a parameter to the method that is normally passed via the
querystring?
If I understand correctly, there are 2 views that share some common part
(that you want to show in a product view and a news view).
You could place the common part in a partial e.g.
app/views/news/_latest_news.html.haml <= note the underscore at the
start of the file name
and include that partial from the view for products and news.
If there are data required, pass them to the partial via locals.
Like this in Layouts and Rendering in Rails — Ruby on Rails Guides
3.4.4 Passing Local Variables
You can also pass local variables into partials, making them even more
powerful and flexible. For example, you can use this technique to reduce
duplication between new and edit pages, while still keeping a bit of
distinct content:
New zone
<%= error_messages_for :zone %>
<%= render :partial => "form", :locals => { :zone => @zone } %>
For you that could be something like (untested !)
product.html.haml
= render “news/latest_news” # note NO underscore here and NO .html.haml
HTH,
Peter
–
Peter V.
http://twitter.com/peter_v
http://rails.vandenabeele.com