find does not raise exception

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

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

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.

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