mbasset / project_overview

Adds a new project overview page to redmine 2+.
MIT License
13 stars 9 forks source link

ActionView::Template::Error undefined method `scoped' for Redmine 3.0.4 #19

Closed amizhang closed 7 years ago

amizhang commented 9 years ago

Hi,

I've just install this plugin, and i'm unable to install this plugin on linux? we dropped in the plugin then ran bundle with the following error:

Started GET "/redmine/overview" for ::1 at 2015-09-01 17:49:54 +0800 Processing by OverviewController#index as HTML Current user: starscream (id=1) Rendered plugins/project_overview/app/views/overview/_projects.html.erb (8.2ms) Rendered common/_tabs.html.erb (14.6ms) Rendered plugins/project_overview/app/views/overview/index.html.erb within layouts/base (18.5ms) Completed 500 Internal Server Error in 37ms (ActiveRecord: 2.4ms)

NoMethodError (undefined method update_or_create' for #<Class:0x00000100b4c7a0>): vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.3/lib/active_record/dynamic_matchers.rb:26:inmethod_missing' plugins/redmine_admin_monitor/lib/redmine_admin_monitor/patches/application_controller_patch.rb:19:in render_500' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/rescuable.rb:80:incall' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/rescuable.rb:80:in rescue_with_handler' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/rescue.rb:15:inrescue_with_handler' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/rescue.rb:32:in rescue in process_action' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/rescue.rb:29:inprocess_action' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:32:in block in process_action' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:inblock in instrument' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in instrument' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:ininstrument' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:30:in process_action' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/params_wrapper.rb:250:inprocess_action' vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.3/lib/active_record/railties/controller_runtime.rb:18:in process_action' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/abstract_controller/base.rb:137:inprocess' vendor/bundle/ruby/2.0.0/gems/actionview-4.2.3/lib/action_view/rendering.rb:30:in process' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal.rb:196:indispatch' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal/rack_delegation.rb:13:in dispatch' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_controller/metal.rb:237:inblock in action' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:76:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:76:indispatch' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:45:in serve' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/journey/router.rb:43:inblock in serve' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/journey/router.rb:30:in each' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/journey/router.rb:30:inserve' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:821:in call' vendor/bundle/ruby/2.0.0/gems/rack-openid-1.4.2/lib/rack/openid.rb:98:incall' vendor/bundle/ruby/2.0.0/gems/request_store-1.0.5/lib/request_store/middleware.rb:9:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/etag.rb:24:incall' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/head.rb:13:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-xml_parser-1.0.2/lib/action_dispatch/xml_params_parser.rb:16:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/params_parser.rb:27:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/flash.rb:260:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:incontext' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/cookies.rb:560:incall' vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.3/lib/active_record/query_cache.rb:36:in call' vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/callbacks.rb:29:in block in call' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:84:inrun_callbacks' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/remote_ip.rb:78:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/show_exceptions.rb:30:incall' vendor/bundle/ruby/2.0.0/gems/railties-4.2.3/lib/rails/rack/logger.rb:38:in call_app' vendor/bundle/ruby/2.0.0/gems/railties-4.2.3/lib/rails/rack/logger.rb:20:inblock in call' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in block in tagged' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:26:intagged' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in tagged' vendor/bundle/ruby/2.0.0/gems/railties-4.2.3/lib/rails/rack/logger.rb:20:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/request_id.rb:21:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:incall' vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in call' vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall'


RubyGems Environment:

amizhang commented 9 years ago

Oh, I removed another plugin (admin_monitor), this error is gone. Sadly, i've met another issue:

ActionView::Template::Error (undefined method scoped' for #<Class:0x00000102309640>): 78: 79: <p> 80: <%= content_tag(:label, l(:label_po_settings_include_project_fields)) %> 81: <%= select_tag("settings[include_project_fields]", options_from_collection_for_select(ProjectCustomField.scoped.order("name ASC"), :id, :name, Setting.plugin_project_overview[:include_project_fields]), { :multiple=> true, :style => "height: 100px;" }) %> 82: <br /> 83: <small><%= l(:label_po_settings_include_project_fields_desc) %></small> 84: </p> app/views/common/_tabs.html.erb:22:inblock in _app_views_commontabs_html_erb_393814558244156170_2192880960' app/views/common/_tabs.html.erb:21:in each' app/views/common/_tabs.html.erb:21:in_app_views_commontabs_htmlerb393814558244156170_2192880960' app/helpers/application_helper.rb:321:in render_tabs' app/views/settings/plugin.html.erb:6:inblock in _app_views_settings_plugin_html_erb__542764159850446559_2193158460' app/views/settings/plugin.html.erb:4:in `_app_views_settings_plugin_html_erb__542764159850446559_2193158460'

Is there any point?

mbasset commented 9 years ago

Can you submit a PR for this issue.

amizhang commented 8 years ago

Already did. Thanks !

Alex-at-dmi commented 8 years ago

Got the same error with.

Environment:
  Redmine version                2.5.2.devel
  Ruby version                   2.1.5-p273 (2014-11-13) [x86_64-linux-gnu]
  Rails version                  4.1.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.10
  Filesystem                     
Redmine plugins:
  project_overview               1.2.0

Any ideas?

edmcdonagh commented 8 years ago

I have the same issue (ActionView::Template::Error (undefined method `scoped') when trying to configure plugin, with

Environment:
  Redmine version                3.2.1.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux-gnu]
  Rails version                  4.2.6
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.9.3
  Git                            2.7.4
  Filesystem                     
Redmine plugins:
  project_overview               1.2.0
  redmine_base_deface            0.0.1
  redmine_multiprojects_issue    3.3.0

@amizhang refers to a pull request already being submitted, but I can't see anything that matches...

Any ideas anyone?

edmcdonagh commented 8 years ago

If the offending line is amended as suggested by the error:

app/views/overview/_settings_project.html.erb

-         <%= select_tag("settings[include_project_fields]", options_from_collection_for_select(ProjectCustomField.scoped.order("name ASC"), :id, :name, Setting.plugin_project_overview[:include_project_fields]), { :multiple=> true, :style => "height: 100px;" }) %>
+         <%= select_tag("settings[include_project_fields]", options_from_collection_for_select(ProjectCustomField.scope.order("name ASC"), :id, :name, Setting.plugin_project_overview[:include_project_fields]), { :multiple=> true, :style => "height: 100px;" }) %>

then the error changes to: ActionView::Template::Error (wrong number of arguments (given 0, expected 2))

If the final <p> section is removed from that file (lines 79 onwards), then no error appears and config is available.

The term ProjectCustomField.scoped also appears in app/views/overview/_projects.html.erb

I suspect that neither of these approaches is the right one to take, but I don't know where the template fields are coming from yet to work out what should be done.

Help anyone?

mbasset commented 8 years ago

Hi @edmcdonagh. I no longer actively develop this project. However if you submit a pull request I would be more than happy to merge it into the master branch.

jancybsec commented 8 years ago

Just had this problem. Based on the conversation in this thread I located the offending "scoped" in the following files and replaced it with "all".

Restarted Redmine and it opens up fine now, not sure if anything else might be broken.

edmcdonagh commented 8 years ago

@jancybsec have you used the plugin with those changes?

After changing the _settings_project.html.erb to ProjectCustomField.all.order the plugin configure link worked, but clicking on Overview at the top triggers the error on the other file:

ActionView::Template::Error (undefined method `scoped' for #<Class:0x00000004f89b08>
Did you mean?  scope
               unscoped):
    38:                                 <th><%= l(:label_project_spi) %></th>
    39:                         <% end %>
    40:                         <th><%= l(:label_project_health) %></th>
    41:                         <% ProjectCustomField.scoped.each do |custom_field| %>
    42:                                 <% next unless Setting.plugin_project_overview[:include_project_fields].to_a.include?(custom_field.id.to_s) %>
    43:                                 <th><%= custom_field.name %></th>
    44:                         <% end %>
  plugins/project_overview/app/views/overview/_projects.html.erb:41:in `_f83b3d63e3deec05d31935e339cebbe8'

Replacing this ProjectCustomField.scoped.each with ProjectCustomField.all.each makes that error go away, but then we get to another one:

ActionView::Template::Error (undefined method `shift' for #<Project::ActiveRecord_Relation:0x000000051a0e00>):
    23:         <% end %>
    24: 
    25:         <tr class="po_project">
    26:                 <td title="<%= project_full_title(project) %>"><%= link_to project.name, project_path(project) %></td>
    27:                 <% if Setting.plugin_project_overview[:stale_enable] %>
    28:                         <td align="center">
    29:                                 <% if project.archived? %>
  plugins/project_overview/app/helpers/project_overview_helper.rb:7:in `project_full_title'

Which relates to app/helpers/project_overview_helper.rb.

Next task I guess is to see if shift has been deprecated from rails too!

jancybsec commented 8 years ago

So, I didn't get that error until I tried to view stale and closed projects. I did some more research and came across the gem activerecord-deprecated_finders, so I rolled back the changes I made to those other files, added the gem to my Redmine Gemfile, did a bundle install, and rebooted redmine. Looks like it's working now and all my projects are showing up!

edmcdonagh commented 8 years ago

I can confirm that reverting the local changes I'd made, git pull, bundle install from the redmine folder and a reboot, and everything seems to work :smile:

@mbasset I suggest you might close this issue as fixed.

mbasset commented 7 years ago

Seems like there are multiple resolutions to this issue. So I am closing this. As always a PR would be welcome that avoids using the old AR finders.