On 12 August 2010 18:56, Scott Le gendre <li...@ruby-forum.com> wrote:
> Hello all. I've been working through some online tutorials, learning ROR
> and have a question on scaffolding. Through the command promt i've ran
> the command:
>
> $ script/generate scaffold Albums
>
> This created the controllers, helpers, models, and views.
> I have a database table titled "albums" and have two records saved
> within
>
> The problem is that the scaffold command did not create what I had
> expected it to create within my views. It only created partial code.
> Below is the code it generated. The same goes for all my Albums views.

The scaffold does not look at an existing table.  You can tell it what
the columns you want are, and it will create a migration to create the
table for you, and will include the columns in the view.  The Getting
Started rails guide at http://guides.rubyonrails.org/ explains how it
works.  I recommend all that all learners work through that guide and
the others there.

Colin

>
> **************************************************************
> <h1>Listing artists</h1>
>
> <table>
>  <tr>
>  </tr>
>
> <% @artists.each do |artist| %>
>  <tr>
>    <td><%= link_to 'Show', artist %></td>
>    <td><%= link_to 'Edit', edit_artist_path(artist) %></td>
>    <td><%= link_to 'Destroy', artist, :confirm => 'Are you sure?',
> :method => :delete %></td>
>  </tr>
> <% end %>
> </table>
>
> <br />
>
> <%= link_to 'New artist', new_artist_path %>
> **************************************************************
>
> When I view the page, it displays the "Show" "Edit" "Destroy" links, and
> displays these for the number of items I have within the database. I
> added an additional item to the database and the "Show" "Edit" "Destroy"
> was displayed an additional time, making the total three to match the
> number of records I have in the database table.
>
> So i went one step further, and figured out that i'm missing the Table
> Headings along with the elements to represent what data is supposed to
> be displaed. For example, if I type <td><%=h album.id %></td>. Now the
> id is displayed for each of the three records within the Albums table.
>
> So, the question is, why isnt it filling out the code I had expected? I
> have over come a lot of issues, mainly because of the tutorial i am
> walking through is using an older version of ROR. This issue I cant find
> an answer on. Anyone have any ideas that could point me in the right
> direction?
>
> Thanks!
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to