Views just returns #

hi im new to ruby on rails, and I have a stupid little problem, when i
do <%= Class1.find(:first) %> in a view file, it just shows “#” on the
website :frowning: how do make it the value in the mySQL table?

John Aston wrote:

hi im new to ruby on rails, and I have a stupid little problem, when i
do <%= Class1.find(:first) %> in a view file, it just shows “#” on the
website :frowning: how do make it the value in the mySQL table?

It is finding the first one, and spitting out a representation of it,
like

#<Class1:0x42924a68 @attributes={…

the < is confusing the HTML parser - but you don’t want that anyway.
You want to display something about that first record, like:

<%= Class1.find(:first).name %>

or perhaps

<% first = Class1.find(:first) %>

<%= first.name %>
<%= first.attribute1 %>
<%= first.attribute2 %>

etc.

Thank you SOOO much, i have tried to find out how to do it for a long
time now. and u gave me a fast and exact answer to my problem, THANKS!!

Thank you
Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs