Forum: Ruby on Rails Error, in my store provider.

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.
Coward (Guest)
on 2006-05-27 20:26
Let me explain the subject title, store provider is Hackey, he's a NPC
that sells items to my users.
<h1>Welcome to Hackey's!</h1>
<h3>Catalog</h3>
<table border="2" bordercolor="red">
<% for items in @items -%>
<% temp12 = Item.find(items.item_id) -%>
<tr><td><%= @temp12.name %></td><td><%= @temp12.add_atk %></td><td><%=
@temp12.add_def %></td><td><%= @temp12.sell %></td></tr>
<% end -%>
</table>
It doesn't like Item.find(items.item_id)
BTW: the table is called hackey, so maybe it dosn't like the items in
@items but, I don't know what to put, how does it plurlize that? in my
model I set set_table_name "hackey".
Daniel H. (Guest)
on 2006-05-27 20:44
(Received via mailing list)
I'm not sure exactly whether Item.find(items.item_id) isn't working - I
would check /logs/development.log to see what SQL is being generated.

In your code, you assign the result of Item.find to "temp12" but later
reference it as "@temp12" - these are separate variables, and you should
drop the "@" in the later references.

I've also got a couple more suggestions - first, you can use Item.find
to
return a collection of items, so that you don't have to call Item.find
for
every iteration of your loop.  Also, it  might be easier/make more sense
to
use the rails convention of having "id" be the name of your primary
field
column, rather than "item_id".  Finally, "temp12" is a pretty
undescriptive
name, you can probably come up with a better one :)

Daniel
Guest (Guest)
on 2006-05-28 19:11
Okay 1 more q. How do I delete that row?
This topic is locked and can not be replied to.