Forum: Ruby on Rails simple dumb rails from datastore question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Roger R. (Guest)
on 2008-10-22 13:44
hi, ive just started learning rails and im trying to make a simple blog

i have the following code on my index page

i can add articles ok but i cant display them

everything ive tried to put between the h1 tags fails?
what should I put between the tags to display the data stores in the
body and title fields

<%= link_to 'New Article', :action => 'new' %>

<% for article in @articles %>

    <td><%= link_to 'Show', article %></td>
    <td><%= link_to 'Edit', edit_article_path(article) %></td>
    <td><%= link_to 'Destroy', article, :confirm => 'Are you sure?',
:method => :delete %></td>
<% end %>

Thanks for any help
Thorsten M. (Guest)
on 2008-10-22 14:33
(Received via mailing list)
assuming that the articles table has a title field, then

<% @articles.each do |article| %>
  <h1> <%= article.title %> </h1>
<% end %>

would display it.

But if I remember right, H1 tags within a table are not valid html
You would have to put them into a TD tag I think. Maybe your
code was right and your browser didn't display it for that
This topic is locked and can not be replied to.