AndyV wrote:
First, I'd suggest using lower case unless you're using a class name
(@Destination => @destination).
How did you set @destination? It would appear that your controller
should have something like:
@land = Land.find(...)
@destinations = @land.destinations.find(:all, :order=>:naam)
Otherwise, your view looks okay except for a possible typo (check the
link_to call, you refer to destinations but have not defined it):
<h2>Destinations in <%= h destination.naam %></h2>
<ul>
<% @destinations.each do |destination| %>
<li><%= link_to destination.naam,
continent_land_destination_path(@land.continent, @land,
destination)%></li>
<% end %>
</ul>
On May 13, 5:06 am, Remco Zwaan <rails-mailing-l...@andreas-s.net>
Hi...
The url structure is not good if i use this code..check >
http://www.goedkoop-vliegen.nu/werelddeel/afrika/land/kenia
The continent(werelddeel)and land(countrie) is not changing......
The code for continents works fine for continents..
http://www.goedkoop-vliegen.nu/werelddeel
<h2>Landen</h2>
<ul>
<% @landen.each do |land| %>
<li><%= link_to land.naam, continent_land_path(land.continent,
land)%></li>
<% end %>
</ul>
When i try this
<h2>destinations</h2>
<ul>
<% @destinations.each do |destination| %>
<li><%= link_to land.naam,
continent_land_destination_path(land.continent, land,
destinations)%></li>
<% end %>
</ul>
I get the error message
undefined local variable or method `land' for
#<ActionView::Base:0xb79f6e44>
This is my setup:
map.resources :continent do |continent |
continent .resources :land do |land|
land.resources :destination
end
end
class Destination < ActiveRecord::Base
has_many :land, :foreign_key => "landcode"
set_table_name "bestemmingen"
set_primary_key "bestemming_id"
has_permalink :stad_zoeknaam
def to_param
stad_zoeknaam
end
end
class Land < ActiveRecord::Base
belongs_to :continent, :foreign_key => "werelddeel_id"
has_many :destination, :foreign_key => "landcode"
set_table_name "landen"
set_primary_key "landcode"
has_permalink :land_zoeknaam
def to_param
land_zoeknaam
end
end
Grtz..remco