zuinqstudio / redmine_chuck_norris

Other
9 stars 5 forks source link

ActionView::TemplateError (undefined method `description' for nil:NilClass) on line #21 #5

Closed camilonova closed 12 years ago

camilonova commented 13 years ago

Hi i have this problem:

Processing ProjectsController#show (for 186.30.231.XXX at 2011-08-24 11:32:23) [GET]
  Parameters: {"action"=>"show", "id"=>"portalweb", "controller"=>"projects"}
Rendering template within layouts/base
Rendering projects/show

ActionView::TemplateError (undefined method `description' for nil:NilClass) on line #21 of vendor/plugins/redmine_chuck_norris/app/views/chuck_norris/_fact.rhtml:
18: 
19: <h3>Chuck Norris Fact</h3>
20: <div id="factWrapper">
21:     <em id="fact"><%= ChuckNorrisHelper::load_random_fact(current_language).description %></em>
22:     <%= link_to_remote l(:next_fact), 
23:                        { :url => { :controller => 'chuck_norris', :action => 'next_fact', :project_id => @project },
24:                          :method => :post,

    vendor/plugins/redmine_chuck_norris/app/views/chuck_norris/_fact.rhtml:21:in `_run_rhtml_vendor47plugins47redmine_chuck_norris47app47views47chuck_norris47_fact46rhtml_locals_fact_object'
    vendor/plugins/redmine_chuck_norris/app/views/projects/show.rhtml:119
    app/helpers/application_helper.rb:868:in `content_for'
    vendor/plugins/redmine_chuck_norris/app/views/projects/show.rhtml:110:in `_run_rhtml_vendor47plugins47redmine_chuck_norris47app47views47projects47show46rhtml'
    app/controllers/projects_controller.rb:165:in `show_without_chuck'
    passenger (3.0.2) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
    passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
    passenger (3.0.2) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
    passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
    passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `send'
    passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application'
    passenger (3.0.2) lib/phusion_passenger/utils.rb:479:in `safe_fork'
    passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:180:in `start'
    passenger (3.0.2) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
    passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application'
    passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
    passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application'
    passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
    passenger (3.0.2) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
    passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
    passenger (3.0.2) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
    passenger (3.0.2) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
    passenger (3.0.2) helper-scripts/passenger-spawn-server:99

Rendering /opt/redmine/public/500.html (500 Internal Server Error)
zuinqstudio commented 13 years ago

Hi Camilo!

thanks for your feedback. Could you tell me what redmine version are you using?

Regards!

camilonova commented 13 years ago

Redmine 1.2.1.stable (PostgreSQL)

Thanks

zuinqstudio commented 13 years ago

I was able to reproduce the exception by deleting the facts table registers. Could you check if 'chuck_norris_facts' table contains any row? Also, I've just commited a fix to avoid the exception when no fact is found.

camilonova commented 13 years ago

Thanks, that solves the problem, how can i get the facts?

zuinqstudio commented 13 years ago

If you followed the installation notes on README.rdoc, the database migration step should have created the table chuck_norris_facts for you. Please, verify this table exists on your redmine database, and that it contains one or more row.

camilonova commented 13 years ago

Yes i have done all the steps, this is the output of the command:

Migrating redmine_chuck_norris...
==  CreateChuckNorrisFacts: migrating =========================================
-- create_table(:chuck_norris_facts)
NOTICE:  CREATE TABLE will create implicit sequence "chuck_norris_facts_id_seq" for serial column "chuck_norris_facts.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "chuck_norris_facts_pkey" for table "chuck_norris_facts"
   -> 0.3577s
==  CreateChuckNorrisFacts: migrated (14.2185s) ===============================

==  TranslateChuckNorrisFacts: migrating ======================================
-- add_column(:chuck_norris_facts, :lang, :string, {:default=>"en"})
   -> 0.0015s
==  TranslateChuckNorrisFacts: migrated (1.9454s) =============================

There is data in the table chuck_norris_facts but it doesnt show in the page, and no errors are given in the log

zuinqstudio commented 13 years ago

I still can't reproduce the issue. Please, check also this:

I'll keep trying to reproduce the problem in my own redmine, and keep you informed.

Regards!

camilonova commented 13 years ago

Thanks, i just look at the table and they has data, but the column lang was empty, so you should give a look at the content loading when setting the language in every row.

redmine=> select * from chuck_norris_facts limit 1;
 id |                description                 | lang 
----+--------------------------------------------+------
  1 | Guns don't kill people, Chuck Norris does. | 
(1 row)

I have done an sql update for all rows in the table and now it works ok, what i do was:

redmine=> update chuck_norris_facts set lang = 'en';
UPDATE 7354

and now i have:

redmine=> select * from chuck_norris_facts where id = 1;
 id |                description                 | lang 
----+--------------------------------------------+------
  1 | Guns don't kill people, Chuck Norris does. | en
(1 row)
byteborg commented 12 years ago

Got similar problem on Postgres. Spanish quotes are loaded with lang set to 'es' and a lot of spaces. English quotes are loaded with a lot of spaces as lang key.

zuinqstudio commented 12 years ago

Thanks for your feedback byteborg. It seems an encoding issue, could you tell me what OS are you using?

Regards!

zuinqstudio commented 12 years ago

Just installed postgres and I'm getting the same issue indeed. I'll keep you informed as soon as I fix it. Thanks again for your interest and sorry for the inconveniences.

Regards!

zuinqstudio commented 12 years ago

I've uploaded a new version that fixes the problem. I'd appreciate it if you could uninstall the plugin and reinstall, and confirm me if everything's ok already.

Thanks!

byteborg commented 12 years ago

Thanks for the fast response. It happens to work now. Neat stuff! Chuck Norris is living in our tracker ;-)

zuinqstudio commented 12 years ago

Thank you for helping us to improve the plugin. Enjoy!