|
|
RubyOnRailsCheatSheetFrom $1Table of contents
Preferred Database Schema
Creating CRUD Applet
for f in Table1 Table2 Table3
do
script/generate scaffold $f
done
Overriding the List Display
<html><head>
<title>My Page Name</title>
</head>
<body>
<h1>My Title</h1>
<% if @nouns %>
<table border="1" style="border-collapse: separate;">
<tr>
<td><b>ColumnTitle1</b></td>
<td><b>ColumnTitle2</b></td>
</tr>
<% @nouns.each do |item| %>
<tr>
<td><%= link_to item.field1, :action => "show", :id => item.id %> </td>
<td><%= item.field2 %> </td>
</tr>
<% end %>
</table>
<% else %>
<i>The table is empty.</i>
<% end %>
<p><%= link_to "Create new record", :action => "new" %></p>
</body></html>
But I Want To Use a Legacy Table Named 'LegacyTable' with the id field named LegacyKey, and Treat it Like a Table Named 'railsexamples'
def self.table_name()
"LegacyTable"
end
def self.primary_key()
"LegacyKey"
end
Tags:
none |