google-code-export / bibapp

Automatically exported from code.google.com/p/bibapp
Other
0 stars 0 forks source link

_work.html.haml results in application 500 error when links_array is nil #184

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. If links_array is nil, e.g. in the case that a work is cached but no longer 
exists in the database.
2.
3.

What is the expected output? What do you see instead?
Expect it to fail gracefully, instead the view fails with a 500 error.  

Please use labels and text to provide additional information.

In _work.html.haml 
http://code.google.com/p/bibapp/source/browse/trunk/app/views/shared/_work.html.
haml#49 we should make sure links_array is not nil at line 55. 

Changing to this took care of the error:

  - if work['links_array'] !=nil
    .links
      - unless links_array.include? 'none'

I'm not sure how it happened exactly, but it seems a work was deleted but still 
cached somewhere. I couldn't find it in Solr either so maybe I have deeper 
problem.

Original issue reported on code.google.com by stirnam...@gmail.com on 22 Nov 2010 at 4:37

GoogleCodeExporter commented 9 years ago
Here's the stack trace:

===== BibApp needs you! ====

* Exception

#<ActionView::TemplateError: 
ActionView::TemplateError (Couldn't find Work with ID=19206) on line #55 of 
app/views/shared/_work.html.haml:
52: 
53:           -#"Find It" Link
54:           -if link==:find_it
55:             =link_to_findit(work)
56: 
57:           -#"Add to Saved" and "Remove from Saved" links
58:           -if link==:saved

    app/helpers/application_helper.rb:183:in `coin'
    app/helpers/application_helper.rb:128:in `link_to_findit'
    app/views/shared/_work.html.haml:55:in `_run_haml_app47views47shared47_work46html46haml_locals_object_work'
    app/views/shared/_work.html.haml:51:in `each'
    app/views/shared/_work.html.haml:51:in `_run_haml_app47views47shared47_work46html46haml_locals_object_work'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:11:in `render'
    haml (2.2.22) lib/haml/helpers.rb:96:in `non_haml'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:11:in `render'
    app/views/works/index.html.haml:82:in `_run_haml_app47views47works47index46html46haml'
    app/views/works/index.html.haml:81:in `each'
    app/views/works/index.html.haml:81:in `_run_haml_app47views47works47index46html46haml'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:13:in `render'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:13:in `render'
    haml (2.2.22) rails/./lib/sass/plugin/rails.rb:20:in `process'
    passenger (2.2.15) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
    passenger (2.2.15) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/utils.rb:252:in `safe_fork'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:163:in `start'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

>

* Clean Backtrace

On line #55 of app/views/shared/_work.html.haml

    52: 
    53:           -#"Find It" Link
    54:           -if link==:find_it
    55:             =link_to_findit(work)
    56: 
    57:           -#"Add to Saved" and "Remove from Saved" links
    58:           -if link==:saved

    app/helpers/application_helper.rb:183:in `coin'
    app/helpers/application_helper.rb:128:in `link_to_findit'
    app/views/shared/_work.html.haml:55:in `_run_haml_app47views47shared47_work46html46haml_locals_object_work'
    app/views/shared/_work.html.haml:51:in `each'
    app/views/shared/_work.html.haml:51:in `_run_haml_app47views47shared47_work46html46haml_locals_object_work'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:11:in `render'
    haml (2.2.22) lib/haml/helpers.rb:96:in `non_haml'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:11:in `render'
    app/views/works/index.html.haml:82:in `_run_haml_app47views47works47index46html46haml'
    app/views/works/index.html.haml:81:in `each'
    app/views/works/index.html.haml:81:in `_run_haml_app47views47works47index46html46haml'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:13:in `render'
    haml (2.2.22) lib/haml/helpers/action_view_mods.rb:13:in `render'
    haml (2.2.22) rails//lib/sass/plugin/rails.rb:20:in `process'
    passenger (2.2.15) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
    passenger (2.2.15) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/utils.rb:252:in `safe_fork'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:163:in `start'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

* Params

{:saved=>#<Saved >}

* Session

{"action"=>"index", "sort"=>"created_at", "controller"=>"works"}

* Request Env

nil

- - - -

Keeping it forever real,
-The BibApp

Original comment by stirnam...@gmail.com on 22 Nov 2010 at 4:40

GoogleCodeExporter commented 9 years ago

Original comment by stirnam...@gmail.com on 22 Nov 2010 at 4:42