Hi guys,

I my application has to be all the "recent news, recent users, recent
pictures"-stuff. This is shown in a rendered view. Right now I'm using a
site controller getting data from different models like

@news = Article.find(:all, :limit => 3, :order => 'created_at DESC')

Of course that doesn't work anymore calling different contollers. I
thought about setting a global variable? I tried to put it in
apllication_helper but I get a nil-error by writing

def recent
  $news = Article.find(:all, :limit => 3, :order => 'created_at DESC')
end

and calling the following in the render

<% for news in $news %>
  <h5><%=h news.title %></h5>
  <p><%=h truncate(news.synopsis, 200) %></p>
  <p><a href="#" title="mehr" class="more">mehr...</a></p>
<% end %>

Is it fine to work with a global variable and if how to do that?

Greetings
Mayo
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to