Mark Bush wrote:
Remco Zwaan wrote:
<li><%= link_to land.naam, land_path(land)%></li>
But i get the error message:
undefined method `land_path' for #<ActionView::Base:0xb75eaf30
This will be related to the internal pluralisation and singularisation
used by Rails (which is why sticking to English words works best).
Still, you can sort this out using the command:
rake routes
This will include a line with a URL matching what you need. There
should be a method name stub to the left. Add "_path" to that.
Also, you can use Rails magic and use:
link_to land.naam, land
Rails will recognise the object and should generate the correct URL. Of
course, the non-English words and irregular pluralisation of your table
name may fox Rails here, too.
Another approach is to teach Rails how to pluralise your model names.
Add inflection entries to your environment.rb file to teach Rails the
relation land<->landen.
Hi..
rake routes
werelddeel_landen GET /werelddeel/:werelddeel_id/landen/:id
So i put werelddeel_landen in the path:
<% @landen.each do |land| %>
<li><%= link_to land.naam, werelddeel_landen_path(land)%></li>
<% end %>
On http://www.goedkoop-vliegen.nu/werelddeel/noord-amerika
Link Afghanistan i get:
http://www.goedkoop-vliegen.nu/werelddeel/afghanistan/landen/noord-amerika
something wrong here!! grgrgrgr
models:
class Land < ActiveRecord::Base
belongs_to :werelddeel, :foreign_key => "werelddeel_id"
set_table_name "landen"
set_primary_key "landcode"
has_permalink :land_zoeknaam
def to_param
land_zoeknaam
end
end
class Werelddeel < ActiveRecord::Base
has_many :land, :foreign_key => "werelddeel_id"
set_table_name "werelddelen"
set_primary_key "werelddeel_id"
has_permalink :zoeknaam
def to_param
zoeknaam
end
end
I case of nice url's (has_permalink, to_param)
i use http://svn.techno-weenie.net/projects/plugins/permalink_fu/
i am getting a headache of this problem 
Grtz..remco