Forum: Ruby on Rails newbie CRUD problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matthew (Guest)
on 2007-01-08 18:46
Hi,

This is my first effort with RoR using the onlamp.com tutorial
(http://www.onlamp.com/lpt/a/5546). I want to simply replace the example
using my own table called "public".

My controller looks like:


class GlycanPublicController < ApplicationController
    scaffold :public

    def list
        @data = public.find_all
    end


end


and the views file list.rhtml:


<html>
<head>
<title>Listing ofdata</title>
</head>

<body>

<h1> List </h1>

<table border=1>
    <tr>
         <td><p align="center"><i><b>ID</b></i></td>
    <td><p align="center"><i><b>Name</b></i></td>

</tr>

<% @data.each do |public| %>
<tr>
  <td><%= public.id %></td>
  <td><%= public.name %></td>
   </tr>
<% end %>
</table>

<p><%= link_to "Create New Entry", :action => "new" %></p>

</body>
</html>



The error generated is:

undefined local variable or method `public' for
#<PublicController:0x37f9dbc>
Daniel H. (Guest)
on 2007-01-08 19:20
(Received via mailing list)
Most likely this will be fixed by capitalizing the "p" in
public.find_all . Also, current usage is find(:all) rather than
find_all, so the complete method would look like:

Public.find(:all)

Daniel
This topic is locked and can not be replied to.