Legacy database: help needed

Sorry if the message below appears twice. Posted it to rubyonrails-talk at google over an hour ago, but have not seen the message appear yet...

I am "new" to Ruby and Rails and jumping right in. That's for me the best way to learn quickly. I am trying to do a simple project on a legacy database. I performed the following steps:

Created a new project, then with the generator scaffold created a simple "recipes" table.

I am coming from IBM iSeries where we have tables and so called record formats. For example the table is named "qvvalup" and the record format is named "qvvaluf", where the record format "handles a single record" so to speak. So we have the same kind of concept as with the rails pluralization: recipes and recipe.

I made copies of folders and files and renamed accordingly. A few examples. The model file "recipe.rb" I copied to "qvvaluf.rb". And the folder "apps/views/recipes" I copied to "apps/views/qvvalup". I have a "qvvalup_controller.rb" and so on. Also did a search and replace in all the files self. So "recipes" to "qvvalup" and then "recipe" to "qvvaluf". Did put in a "map" in "routes.rb" as well:

map.resources :qvvalup

Next step was editing my model file "qvvaluf":

set_table_name "qvvalup" set_primary_key "qvqvcode"

to be able to handle the pluralization and primary key.

I am getting an error when going to localhost:3000/qvvalup. The error seems to be in my "index.html.erb" when it is trying to create my "show link":

undefined method `qvvaluf_path' for #<ActionView::Base:0x4953c34>

My "index.html.erb" is below and I can't find anything that I might have forgotten to rename or whatever. Is it maybe the routing that is going wrong here ? Or something else ? Any help appreciated...

Thanks,        Mark

"index.html.erb":

<h1>Werken met valuta</h1>

<table> <tr>    <th>Valuta</th>    <th>Omschrijving</th>    <th>Koers</th>    <th>Aantal decimalen</th> </tr>

<% for qvvaluf in @qvvalup %> <tr>    <td><%=h qvvaluf.qvqvcode %></td>    <td><%=h qvvaluf.qvqvomsc %></td>    <td><%=h qvvaluf.qvqvkoer %></td>    <td><%=h qvvaluf.qvqvaant %></td>    <td><%= link_to 'Show', qvvaluf %></td>    <td><%= link_to 'Edit', edit_qvvaluf_path(qvvaluf) %></td>    <td><%= link_to 'Destroy', qvvaluf, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %> </table>

<br />

<%= link_to 'New qvvaluf', new_qvvaluf_path %>

undefined method `qvvaluf_path' for #<ActionView::Base:0x4953c34>

Those methods come from routes.rb. DO you still have
map.resources :recipes in there ?

Fred

Frederick Cheung wrote:

undefined method `qvvaluf_path' for #<ActionView::Base:0x4953c34>

Those methods come from routes.rb. DO you still have map.resources :recipes in there ?

Fred

Yes, as stated I have added

map.resources :qvvalup

to "routes.rb". The rest I left as is after the scaffold generation. So the map to recipes is still in there. I addad my line just after the map recipes line.

The rest is left as well. So at the bottom of the file, there are two 'general" routes.

Ryan Bigg wrote:

qvvalup is not the same as qvvaluf, unless you're speaking a language I'm not recognising. Rails works "best" with english words and pluralization. Somewhere in your app you're referencing qvvaluf_path... probably a scaffold somewhere. Got a stack trace for us? ----- Ryan Bigg Freelancer http://frozenplague.net

I am working with a legacy database and so pluralization is out of the question. But in the same way Rails uses pluralization, we have "generalized" and use P as suffix for tables and F as suffix for records. Hence the qvvalup and qvvaluf.

You are right for the scaffold. Used the scaffold generator to provide for a skeleton for the recipes example, then just did a very basic search/replace, replacing recipes with qvvalup and recipe with qvvaluf.

Below a stack trace and my index.html.erb where you can find all my "replacements" of recipes and recipe. Perhaps I should have replaced recipe with qvvalup insteas of qvvaluf ?

Stacktrace:

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in `__send__' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in `polymorphic_url' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:119:in `polymorphic_path' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:91:in `url_for' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:228:in `link_to' app/views/qvvalup/index.html.erb:17 app/views/qvvalup/index.html.erb:11:in `each' app/views/qvvalup/index.html.erb:11 app/controllers/qvvalup_controller.rb:7:in `index'

Index.html.erb:

<h1>Werken met valuta</h1>

<table>   <tr>     <th>Valuta</th>     <th>Omschrijving</th>     <th>Koers</th>     <th>Aantal decimalen</th>   </tr>

<% for qvvaluf in @qvvalup %>   <tr>     <td><%=h qvvaluf.qvqvcode %></td>     <td><%=h qvvaluf.qvqvomsc %></td>     <td><%=h qvvaluf.qvqvkoer %></td>     <td><%=h qvvaluf.qvqvaant %></td>     <td><%= link_to 'Show', qvvaluf %></td>     <td><%= link_to 'Edit', edit_qvvaluf_path(qvvaluf) %></td>     <td><%= link_to 'Destroy', qvvaluf, :confirm => 'Are you sure?', :method => :delete %></td>   </tr> <% end %> </table>

<br />

<%= link_to 'New qvvaluf', new_qvvaluf_path %>