Defect #7604

ActionView::TemplateError (undefined method `name' for nil:NilClass)

Added by Morgan Jones over 11 years ago. Updated over 11 years ago.

Status:ClosedStart date:2011-02-11
Priority:NormalDue date:
Assignee:-% Done:


Target version:1.2.0
Resolution:Fixed Affected version:1.1.0


My school (Regis Jesuit High School) is using Redmine to manage our newsroom publication workflow. It's super useful, but I keep getting an error when submitting edits to certain issues.


Processing IssuesController#update (for at 2011-02-10 17:44:42) [PUT]  Parameters: {"time_entry"=>{"comments"=>"", "activity_id"=>"", "hours"=>""}, "commit"=>"Submit", "notes"=>"hello", "action"=>"update", "_method"=>"put", "authenticity_token"=>"D0eCFy/UxVBiZvKK0db3OwQacDvMpuAwprt+q8P2JpE=", "id"=>"100", "issue"=>{"start_date"=>"2011-02-09", "estimated_hours"=>"", "priority_id"=>"4", "parent_issue_id"=>"", "lock_version"=>"4", "fixed_version_id"=>"6", "done_ratio"=>"0", "assigned_to_id"=>"1", "subject"=>"Minecraft Feature Spread", "tracker_id"=>"21", "due_date"=>"", "status_id"=>"7", "description"=>"This spread will be a
 look into the wondrous world of Minecraft as well as some of the guys who play 
it at RJ.\r\n\r\nMinecraft is a very cool game that is much like building a model train set: only a few people appreciate those who play it and the rest think i
t's a complete waste of time.\r\n\r\nHowever, people have made some pretty aweso
me worlds with Minecraft, including the social media platform Reddit, whose play
ers have built things like the Golden Gate bridge and the Statue of Liberty, som
etimes to scale.\r\n\r\nAlthough it seems like a creativity tool only, Minecraft adds the twist of monsters that come out at night and attack the player, making
 it a combination of creativity and tower defense."}, "controller"=>"issues", "a

ActionView::TemplateError (undefined method `name' for nil:NilClass) on line #10
 of app/views/mailer/_issue_text_plain.rhtml:7: <%=l(:field_assigned_to)%>: <%= issue.assigned_to %>
8: <%=l(:field_category)%>: <%= issue.category %>
9: <%=l(:field_fixed_version)%>: <%= issue.fixed_version %>
10: <% issue.custom_values.each do |c| %><%= %>: <%= show_value(c) %>
11: <% end %>
13: <%= issue.description %>

    app/views/mailer/_issue_text_plain.rhtml:10:in `_run_rhtml_app47views47mailer47_issue_text_plain46rhtml_locals_issue_issue_text_plain_issue_url_object'
    app/views/mailer/_issue_text_plain.rhtml:10:in `_run_rhtml_app47views47mailer47_issue_text_plain46rhtml_locals_issue_issue_text_plain_issue_url_object'
    app/views/mailer/issue_edit.text.plain.rhtml:9:in `_run_rhtml_app47views47mailer47issue_edit46text46plain46rhtml'
    app/models/mailer.rb:398:in `render_multipart'
    app/models/mailer.rb:79:in `issue_edit'
    app/models/journal_observer.rb:24:in `after_create'
    /usr/lib/ruby/1.8/observer.rb:185:in `notify_observers'
    /usr/lib/ruby/1.8/observer.rb:184:in `each'
    /usr/lib/ruby/1.8/observer.rb:184:in `notify_observers'
    app/models/journal.rb:43:in `save'
    app/models/issue.rb:848:in `create_journal'    app/models/issue.rb:554:in `save_issue_with_child_records'
    app/models/issue.rb:536:in `save_issue_with_child_records'    app/controllers/issues_controller.rb:170:in `update'
    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'

Rendering /etc/redmine/public/500.html (500 Internal Server Error)

I actually did manage to fix this one by adding two or three lines of code in app/views/mailer/_issue_text_plain.rhtml and app/views/mailer/_issue_text_html.rhtml:



<% issue.custom_values.each do |c| %><%= %>: <%= show_value(c) %>

Replace with:

<% issue.custom_values.each do |c| %>
<% unless c.nil? || c.custom_field.nil? %>
<%= %>: <%= show_value(c) %>
<% end %>



<% issue.custom_values.each do |c| %>
  <li><%=h %>: <%=h show_value(c) %></li>
<% end %>

Replace with:

<% issue.custom_values.each do |c| %>
  <% unless c.nil? || c.custom_field.nil? %>
  <li><%=h %>: <%=h show_value(c) %></li>
  <% end %>
<% end %>

Apparently one of the custom fields for an issue can be nil? Why exactly is this? I'll admit, my fix is kind of a kludge but does the job nicely...

Environment Info

About your application's environment
Ruby version              1.8.7 (i686-linux)
RubyGems version          1.3.7
Rack version              1.0
Rails version             2.3.5
Active Record version     2.3.5
Active Resource version   2.3.5
Action Mailer version     2.3.5
Active Support version    2.3.5
Application root          /etc/redmine
Environment               production
Database adapter          mysql
Database schema version   20101115203855

About your Redmine plugins
Redmine Wiki Extensions plugin                   0.2.4
Redmine Whining plugin                           0.0.4
Redmine User Profiles plugin                     0.0.2
Redmine Ultraviolet Syntax highlighting plugin   0.0.3
Redmine JChat                                    0.2.0
Redmine Theme Changer plugin                     0.0.2
Redmine ICalendar Export Plugin (aka redmics)    1.1

Other Info

Redmine Version: 1.1.1 SVN
MySQL Version: mysql  Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (i686) using readline 6.1


Associated revisions

Revision 4891
Added by Jean-Philippe Lang over 11 years ago

Do not keep illegitimate custom_values when setting custom_field_values (#7604).

Revision 4892
Added by Jean-Philippe Lang over 11 years ago

Use #custom_field_values to display issue custom fields in email, just like on regular views (#7604).


#1 Updated by Jean-Philippe Lang over 11 years ago

  • Status changed from New to Closed
  • Target version set to 1.2.0
  • Resolution set to Fixed

r4891 and r4892 should fix the problem.

Also available in: Atom PDF