By does nothing I assume you mean that an empty array is returned. A
string literal with single quotes isn't interpolated, so the query
actually says WHERE wereldeel_id = '#{werelddeel_id}' (which obviously
matches nothing). You need double quotes for interpolation to happen,
although it's not clear to me why you can't just do :werelddeel_id =>
werelddeel_id or even easier:
Land.find_all_by_werelddeel_id(werelddeel_id)
By does nothing I assume you mean that an empty array is returned. A
string literal with single quotes isn't interpolated, so the query
actually says WHERE wereldeel_id = '#{werelddeel_id}' (which obviously
matches nothing). You need double quotes for interpolation to happen,
although it's not clear to me why you can't just do :werelddeel_id =>
werelddeel_id or even easier:
Land.find_all_by_werelddeel_id(werelddeel_id)
Werelddeel controller
def show
@werelddeel = Werelddeel.find(params[:werelddeel_id])
@landen = Land.find_all_by_werelddeel_id(werelddeel_id)
end
errormessage
Couldn't find Werelddeel without an ID
ok, the default parameter for the show action is named id.
def show
@werelddeel = Werelddeel.find(params[:id])
@landen = Land.find_all_by_werelddeel_id(@werelddeel.id)
end
should work then
but
def show
@werelddeel = Werelddeel.find(params[:id])
@landen = @werelddeel.landen # or .land, (?) with your naming
end
read the development.log
this shows you lots of details for all calls your app makes
especially which parameters are sent to it. clear the file in a
texteditor,
save the empty file, run your app and have a look at it. this will help
you a lot finding detail bugs like that.
or just have a look at the output of your server, that's just the same
as in the logfile
Werelddeel controller
def show
@werelddeel = Werelddeel.find(params[:werelddeel_id])
@landen = Land.find_all_by_werelddeel_id(werelddeel_id)
end
errormessage
Couldn't find Werelddeel without an ID
ok, the default parameter for the show action is named id.
def show
@werelddeel = Werelddeel.find(params[:id])
@landen = Land.find_all_by_werelddeel_id(@werelddeel.id)
end
should work then
but
def show
@werelddeel = Werelddeel.find(params[:id])
@landen = @werelddeel.landen # or .land, (?) with your naming
end
read the development.log
this shows you lots of details for all calls your app makes
especially which parameters are sent to it. clear the file in a
texteditor,
save the empty file, run your app and have a look at it. this will help
you a lot finding detail bugs like that.
or just have a look at the output of your server, that's just the same
as in the logfile
NameError (undefined local variable or method `werelddeel_id' for
#<WerelddeelController:0xb7735aac>):
/app/controllers/werelddeel_controller.rb:13:in `show'