Forum: Ruby on Rails outputing table data

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.
Fcf5e28e2e7ce245632a4a29896e6799?d=identicon&s=25 scott (Guest)
on 2006-04-28 10:23
Hi,

Just come across thi sproblem, and jsut cant find out what is wrong with
it, if any one has any suggestions it would be good.

in my projects_controller.rb I have

def list
    @project_pages, @projects = paginate :projects, :per_page => 10
end

and ths list.rhtml file I have

<table>
    <tr>
        <th>Name</th>
        <th>Actions</th>
    </tr>
    <% if @projects %>
	    <% for project in @projects %>
		    <tr>
		       <td><% project.name %></td>
		       <td>
			<%= link_to 'Show', :action => 'show', :id => project %>
			<%= link_to 'Edit', :action => 'edit', :id => project %>
		       </td>
	       </tr>
	    <%end%>
    <%end%>
</table>

When I view this page the project.name column in the table appears
blank, however the show and edit links work correctly.

Any suggestions to whats going wrong?

thanks
scott
Fcf5e28e2e7ce245632a4a29896e6799?d=identicon&s=25 scott (Guest)
on 2006-04-28 10:39
ok i have fixed this by adding <%=h instead of <% not to sure what this
does, (apart form make it work!!) so if anyone knows please let me know

thanks
scott
882cc23c77c5c6d27613c51396a02a0d?d=identicon&s=25 Stephen Bartholomew (Guest)
on 2006-04-28 11:27
(Received via mailing list)
h() is short for html_escape() - it turns html text like:
<b>word</b>
into:
&lt;b&gt;word&lt;/b&gt;
meaning that the rendered text will show as <b>word</b> rather than than
'word' in bold.

Hope that makes sense :0)

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