Defect #7297

Undefined method `visible_custom_field_values' in projects/show.rhtml

Added by Adam DeJardine about 9 years ago. Updated over 8 years ago.

Status:ReopenedStart date:2011-01-11
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Resolution:Invalid Affected version:1.1.0

Description

When accessing the Overview page of any project, the following error gets logged (and a 500 gets sent to the browser)

ActionView::TemplateError (undefined method `visible_custom_field_values' for #<Project:0x7f20a6bda448>) on 
line #19 of app/views/projects/show.rhtml:
16:     <li><%=l(:label_subproject_plural)%>:
17:         <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
18:   <% end %>
19:     <% @project.visible_custom_field_values.each do |custom_value| %>
20:     <% if !custom_value.value.blank? %>
21:        <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
22:     <% end %>

    app/views/projects/show.rhtml:19:in `_run_rhtml_app47views47projects47show46rhtml'
    app/controllers/projects_controller.rb:166:in `show'
    /usr/lib/ruby/1.8/phusion_passenger/rack/request_handler.rb:92:in `process_request'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/utils.rb:184:in `safe_fork'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:163:in `start'
    /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:213:in `start'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `__send__'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in `main_loop'
    /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    /usr/lib/phusion_passenger/passenger-spawn-server:61

Rails version: 2.3.5
Ruby version: 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]
Revision: r4680

redmine-1.1.0_fix.patch Magnifier (578 Bytes) Ilya Kharmatsky, 2011-01-11 23:06


Related issues

Duplicated by Redmine - Defect #7305: undefined method `visible_custom_field_values' in users/s... Closed 2011-01-12
Duplicated by Redmine - Defect #7665: Error 500 Closed 2011-02-20

History

#1 Updated by Ilya Kharmatsky about 9 years ago

Here is a patch that worked for me and resolved the problem:

--- app/views/projects/show.rhtml_orig  2011-01-11 21:56:48.000000000 +0000
+++ app/views/projects/show.rhtml       2011-01-11 21:57:14.000000000 +0000
@@ -16,7 +16,7 @@
        <li><%=l(:label_subproject_plural)%>:
            <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
   <% end %>
-       <% @project.visible_custom_field_values.each do |custom_value| %>
+       <% @project.custom_field_values.each do |custom_value| %>
        <% if !custom_value.value.blank? %>
           <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
        <% end %>

#2 Updated by Ilya Kharmatsky about 9 years ago

The previous comment is unreadable, so I'm attaching the patch as a file.

#3 Updated by Jean-Philippe Lang about 9 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

Same as #7291. Make sure you're using a fresh Redmine code.
This method is defined in acts_as_customizable.

#4 Updated by Adam DeJardine about 9 years ago

I updated to HEAD (currently r4702). The problem still exists.

The patch, however, works like a charm! :-)

#5 Updated by Tristan Knight about 9 years ago

I filed the same issue #7291.

i also tried updating to the latest as suggested in the issue i filed to find no change

however this patch worked a treat! thanks

#6 Updated by Adam DeJardine about 9 years ago

  • Status changed from Closed to Reopened

The same change needs to be made to app/views/users/show.rhtml

Reopening this defect as it is still a problem in r4702 (the current HEAD)

#7 Updated by Artem La about 9 years ago

Adam DeJardine wrote:

The same change needs to be made to app/views/users/show.rhtml

Reopening this defect as it is still a problem in r4702 (the current HEAD)

I've already added #7305 bug while this was closed. So probably need to close one of them.

#8 Updated by Jean-Philippe Lang about 9 years ago

Reopening this defect as it is still a problem in r4702 (the current HEAD)

Can not reproduce with a fresh Redmine 1.1.0. What does a svn status gives?

#9 Updated by Adam DeJardine about 9 years ago

I've made some tweaks after this point (including adding Ilya's patch). There's been a decent number of commits since r4702, so if you can't reproduce at HEAD then I'll stand behind you closing the issue :-)

redmine@redmine:/usr/share/redmine-1.1$ svn status
?       multi_repo.patch
?       app/helpers/repositories_helper.rb.orig
M       app/helpers/queries_helper.rb
M       app/models/mailer.rb
M       app/views/layouts/base.rhtml
M       app/views/users/show.rhtml
M       app/views/projects/show.rhtml
?       app/views/issues/_changesets.rhtml.orig
M       app/views/issues/bulk_edit.rhtml
?       db/migrate/109_add_name_to_repository.rb
?       vendor/plugins/redminelocalavatars
?       vendor/plugins/redmin-mylyncon
?       vendor/plugins/redmine_favicon
?       vendor/plugins/redmine_opensearch
?       vendor/plugins/redmine_logs
M       vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb
M       vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb
M       vendor/plugins/coderay-0.9.2/lib/coderay/helpers/file_type.rb
M       vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
M       vendor/plugins/gravatar/Rakefile
M       vendor/plugins/gravatar/lib/gravatar.rb
M       vendor/plugins/gravatar/spec/gravatar_spec.rb
M       vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
M       vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb
M       config/locales/en.yml
?       config/initializers/spent_time_query_patch.rb
?       lib/spent_time_query_patch.rb
M       lib/redmine/info.rb
?       public/redmine
redmine@redmine:/usr/share/redmine-1.1$ svn info
Path: .
URL: http://redmine.rubyforge.org/svn/branches/1.1-stable
Repository Root: http://redmine.rubyforge.org/svn
Repository UUID: e93f8b46-1217-0410-a6f0-8f06a7374b81
Revision: 4702
Node Kind: directory
Schedule: normal
Last Changed Author: tmaruyama
Last Changed Rev: 4693
Last Changed Date: 2011-01-11 10:28:23 -0500 (Tue, 11 Jan 2011)

redmine@redmine:/usr/share/redmine-1.1$ 

#10 Updated by Jean-Philippe Lang about 9 years ago

There is a good chance that your 500 error come from the modified:

M       vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb

Can you post a diff of this file?

#11 Updated by Adam DeJardine about 9 years ago

redmine@redmine:/usr/share/redmine-1.1$ svn diff vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
Index: vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
===================================================================
--- vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb     (revision 4702)
+++ vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb     (working copy)
@@ -50,21 +50,6 @@
                                  :order => 'position')
         end

-        # Sets the values of the object's custom fields
-        # values is an array like [{'id' => 1, 'value' => 'foo'}, {'id' => 2, 'value' => 'bar'}]
-        def custom_fields=(values)
-          values_to_hash = values.inject({}) do |hash, v|
-            v = v.stringify_keys
-            if v['id'] && v.has_key?('value')
-              hash[v['id']] = v['value']
-            end
-            hash
-          end
-          self.custom_field_values = values_to_hash
-        end
-
-        # Sets the values of the object's custom fields
-        # values is a hash like {'1' => 'foo', 2 => 'bar'}
         def custom_field_values=(values)
           @custom_field_values_changed = true
           values = values.stringify_keys
@@ -77,10 +62,6 @@
           @custom_field_values ||= available_custom_fields.collect { |x| custom_values.detect { |v| v.custom_field == x } || custom_values.build(:custom_field => x, :value => nil) }
         end

-        def visible_custom_field_values
-          custom_field_values.select(&:visible?)
-        end
-
         def custom_field_values_changed?
           @custom_field_values_changed == true
         end
redmine@redmine:/usr/share/redmine-1.1$ diff vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb ../redmine/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
redmine@redmine:/usr/share/redmine-1.1$

Looks like that's the problem... when I upgraded from 1.0 to 1.1 I copied the contents of vendor/plugins to the 1.1 install which overwrote this file.

#12 Updated by Jean-Philippe Lang about 9 years ago

  • Status changed from Reopened to Closed

Adam DeJardine wrote:

[...]

Looks like that's the problem... when I upgraded from 1.0 to 1.1 I copied the contents of vendor/plugins to the 1.1 install which overwrote this file.

See my first comment...
Anyway, you should never do this.

#13 Updated by Vasili Pupkin about 9 years ago

Jean-Philippe Lang wrote:

See my first comment...
Anyway, you should never do this.

I think the problem exactly here.... It is a serious bug in documentation - see Redmine Upgrade
Step 3 - "Perform the upgrade has following sub-step:
5. Copy the folders of your installed plugins into new installation directory

There is no clear separation between the "custom" plugins and "built-in" plugins, and as result we are taking our custom plugins from the previous version, but scrambling the "built-in" plugins with the old code base.

#14 Updated by Wayne He almost 9 years ago

Yes,I encountered the same issue when I upgraded from 0.9.3 to 1.1.1. And there are 2 different issues,see following:

ActionView::TemplateError (undefined method `visible_custom_field_values' for #<Project:0x7f20a6bda448>) on 
line #19 of app/views/projects/show.rhtml:
16:     <li><%=l(:label_subproject_plural)%>:
17:         <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
18:   <% end %>
19:     <% @project.visible_custom_field_values.each do |custom_value| %>

This one could be resoved by the patch.
ActionView::TemplateError (undefined method `visible_custom_field_values' for #<User:0xb692d914>) on line #12 of app/views/users/show.rhtml:
9: <% unless @user.pref.hide_mail >
10: <li><=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') ></li>
11: < end >
12: < @user.visible_custom_field_values.each do |custom_value| >
13: < if !custom_value.value.blank? >
14: <li><=h custom_value.custom_field.name%>: <%=h show_value(custom_value) ></li>
15: < end %>

This one maybe be caused by overwrote the directory "plugins".

#15 Updated by Dave Abrahams over 8 years ago

Vasili Pupkin wrote:

I think the problem exactly here.... It is a serious bug in documentation - see Redmine Upgrade
Step 3 - "Perform the upgrade has following sub-step:
5. Copy the folders of your installed plugins into new installation directory

There is no clear separation between the "custom" plugins and "built-in" plugins, and as result we are taking our custom plugins from the previous version, but scrambling the "built-in" plugins with the old code base.

I can't believe this hasn't been addressed in the documentation already! It's very little consolation to find this ticket after having already screwed up installation.

#16 Updated by Dave Abrahams over 8 years ago

  • Status changed from Closed to Reopened

reopening since this is a serious documentation bug and I'm not privileged to edit the wiki page and fix it myself

#17 Updated by Etienne Massip over 8 years ago

What would you write then ?

Also available in: Atom PDF