I have a posts controller and a pages controller for ‘static’ pages ie
my homepage
I want to have the latest post shown on the homepage… accessing the
posts controller from within the pages controller
Is there a way I can do this?
thanks
I have a posts controller and a pages controller for ‘static’ pages ie
my homepage
I want to have the latest post shown on the homepage… accessing the
posts controller from within the pages controller
Is there a way I can do this?
thanks
On Fri, Apr 30, 2010 at 7:02 AM, the batman [email protected]
wrote:
I have a posts controller and a pages controller for ‘static’ pages ie
my homepage
I want to have the latest post shown on the homepage… accessing the
posts controller from within the pages controller
The posts controller doesn’t come into the picture; just get the post
info in your pages controller.
def homepage
@post = Post.latest # assuming a named scope
render …
Hassan S. ------------------------ [email protected]
twitter: @hassan
what is render for?
On Fri, Apr 30, 2010 at 7:58 AM, the batman [email protected]
wrote:
what is render for?
I just put that there to represent standard controller stuff – whatever
else you have in that controller method.
If you mean what does render do?
, it’s time to open the API docs
–
Hassan S. ------------------------ [email protected]
twitter: @hassan
that’s what I assumed but wasn’t sure if you meant render a partial…
got it working now
thanks!
in …/layout/application.rhtml
there will be home page
<%= render :partial => ‘layouts/homepage’ %>
in home page call your all pages …which u want to show
<%= render :partial => ‘layouts/posts’ %>
<%= render :partial => ‘layouts/news’ %>
…etc
-Shyam
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs