This is the list file for the view "news":
<h1>Listing news_posts</h1>
<table>
<tr>
<% for column in NewsPost.content_columns %>
<th><%= column.human_name %></th>
<% end %>
</tr>
<% for news_post in @news_posts %>
<tr>
<% for column in NewsPost.content_columns %>
<td><%=h news_post.send(column.name) %></td>
<% end %>
<td><%= link_to 'Show', :action => 'show', :id => news_post %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => news_post %></td>
<td><%= link_to 'Destroy', { :action => 'destroy', :id => news_post }, :confirm => 'Are you sure?' %></td>
</tr>
<% end %>
</table>
<%= link_to 'Previous page', { :page => @news_post_pages.current.previous } if @news_post_pages.current.previous %>
<%= link_to 'Next page', { :page => @news_post_pages.current.next } if @news_post_pages.current.next %>
<br />
<%= link_to 'New news_post', :action => 'new' %>
<% for show in @pooponastick %>
pooponastick!<br />
<% end %>
This is the application.rb controller:
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
@upcoming_shows = Show.find_upcoming_shows
end
This is the show model:
class Show < ActiveRecord::Base
belongs_to :venue
def self.find_upcoming_shows
find( :all,
:conditions => "date >= now()",
:order => "date asc")
end
end