Sunday, January 29, 2006

Finding the records and displaying them

In *_controller.rb (resource_controller.rb for our example) we can get all the resources from the database in our function using

@resources = Resource.find_all



Then we can traverse through them in .rhtml file using


<% @resources.each do |resource| %>

<%= link_to resource.title, :action => "show", :id => resource.id %>
<%= resource.date %>

<% end %>

0 Comments:

Post a Comment

<< Home

eXTReMe Tracker