get DB data to rhtml file

Mark Preston wrote:

I am trying to get data out of a database to my rhtml file. The files look like this:

Model ------- mystuff.rb

class Mystuff < ActiveRecord::Base   set_table_name "mytable"   set_primary_key "id" end

Controllers --------------


require 'Mystuff'

class MystuffController < ApplicationController

    def read

       @me = Mystuff.find( :all)

    end   end

Index ----------


<h1>Mystuff#index</h1> <p><%mystuff.each do |mr|%></p> <h1>mr.m1</h1> <% end %>

In addition to Fredericks point, you might also want to check the validity of the html that will output.

The closing </p> tag is inside the loop and thus will be repeated for each element:

<h1>Mystuff#index</h1> <p></p> <h1>Stuff1</h1> </p> <h1>Stuff2</h1> </p> <h1>Stuff3</h1>

And so on. Hope this sheds a little light.