Hi
I have the code
def index
@messages = message_thread.messages
end
private
def message_thread
begin
current_user.message_threads.find(params[:thread_id])
rescue ActiveRecord::RecordNotFound
logger.warn “No permission or thread_id nil”
render :file => “#{RAILS_ROOT}/public/404.html”
end
end
And even if params[:id] does not have any values I dont get any
exception . I can’t figureout why. Please help
Thanks
2010/8/25 Tom M. [email protected]
begin
current_user.message_threads.find(params[:thread_id])
rescue ActiveRecord::RecordNotFound
The problem is here:
logger.warn "No permission or thread_id nil"
render :file => "#{RAILS_ROOT}/public/404.html"
end
end
And even if params[:id] does not have any values I dont get any
exception . I can’t figureout why. Please help
You have a rescue statement which is overriding the exception:
current_user.message_threads.find(params[:thread_id]) rescue
ActiveRecord::RecordNotFound
remove the rescue first you will see an exception.
Thanks
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/)
|
Malawi
Cell: +265 999 465 137 | +265 881 234 717
“Many people doubt open source software and probably don’t realize that
there is an alternative… which is just as good…” – Kevin Scannell
Hi Edmond
Thanks for your reply. The problem is not that. Even it enters in
rescue, it does not render :file => “#{RAILS_ROOT}/public/404.html”. But
it continues execution and I get problem at @messages =
message_thread.messages
as nil.messages
Thanks
Tom