/ Published in: Rails
URL: http://www.railsforum.com/viewtopic.php?id=737
Expand |
Embed | Plain Text
module WidgetsHelper def recent_topics_widget(limit = 5) topics = Topic.find(:all, :order => 'created_at DESC', :limit => limit) render :partial => 'widgets/recent_topics', :locals => { :topics => topics } end # all other widgets go here end # in application.rb helper :widgets # loads the WidgetsHelper for all views # in views/widgets/_recent_topics.rhtml <div id="recent_topics" class="widget"> <% for topic in topics %> <div class="topic"><%= topic.name %></div> <% end %> </div>
You need to login to post a comment.
