Enumeration API change in r2472 - undefined method 'get_values'
Added by Eric Davis almost 16 years ago
An API change was recently commited to trunk that will affect any plugin using Activities, Priorities, or Document Categories. The error you might see is undefined method 'get_values'
. In r2472 Enumeration#get_values
and Enumeration#default
was removed in favor of using named scopes. If your plugin is following trunk the upgrade should be easy.
Change:
Enumeration::get_values('ACTI')
To:
Enumeration.activities
If you have any questions or need any help, open a new forum topic or post a comment here.
Eric
Replies (15)
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Tim Klein almost 16 years ago
... to get the stuff to do plugin running
edit in vendor/plugins/stuff_to_do/app/models/next_issue_filter.rb
change line 8 to
self.priorities = Enumeration.priorities
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Eric Davis almost 16 years ago
Tim Klein wrote:
... to get the stuff to do plugin running
edit in vendor/plugins/stuff_to_do/app/models/next_issue_filter.rb
Thanks, I'll be updating all my plugins soon to handle this change.
Eric
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Eric Davis almost 16 years ago
Instead of just changing get_values('IPRI')
to priorities
, I ended up implementing a workaround in my Stuff To Do plugin. It should detect which Enumeration API to use automatically.
Eric
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Tim Klein almost 16 years ago
sounds pretty interesting
i will check it out!
thanks for that
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Tim Klein almost 16 years ago
i would say a func like this should be implemented in the redmine core
on one hand i can understand why not
on the other it is bad to change the api calls because it breaks heaps of plugins....
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Eric Davis almost 16 years ago
Tim Klein wrote:
i would say a func like this should be implemented in the redmine core
I disagree, if the core had to manage workarounds for third party code it would become unmaintainable. Until Redmine has an public/private API spec (like Merb) the burden has to go on the plugin developers for staying up to date (saying this as a plugin developer myself).
on the other it is bad to change the api calls because it breaks heaps of plugins....
It was changed in trunk, which is where things are allowed to break. I made this forum post to let any plugin developers know of the API change so they can work around it like I did.
Eric
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Tim Klein almost 16 years ago
Eric Davis wrote:
I disagree, if the core had to manage workarounds for third party code it would become unmaintainable. Until Redmine has an public/private API spec (like Merb) the burden has to go on the plugin developers for staying up to date (saying this as a plugin developer myself).
It was changed in trunk, which is where things are allowed to break. I made this forum post to let any plugin developers know of the API change so they can work around it like I did.
yea otherwise it causes the same mess as wordpress is nowadays
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Damien Cirotteau almost 15 years ago
Actually there is a new change in the API for the upcoming 0.9 release. Any hints on how to fixe that. I am not at all a RoR developer but I am willing to help on fixing the plugins if I someone can provide me any hints
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Damien Cirotteau almost 15 years ago
I have fixed it for the stuff_to_do plugin :
I have changed
Enumeration.priorities
in
IssuePriority.all
Eric do you accept patches to your plugins ?
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Damien Cirotteau almost 15 years ago
Here is the full patch. It is there only if it can help other. I will submitt it to your redmine Eric.
--- a/app/models/stuff_to_do_filter.rb +++ b/app/models/stuff_to_do_filter.rb @@ -27,7 +27,9 @@ class StuffToDoFilter private # Wrapper around Redmine's API since Enumerations changed in r2472 def get_priorites - if Enumeration.respond_to?(:priorities) + if IssuePriority.respond_to?(:all) + return IssuePriority.all + elsif Enumeration.respond_to?(:priorities) return Enumeration.priorities else return Enumeration::get_values('IPRI')
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Damien Cirotteau almost 15 years ago
- bulk_time_entries : https://projects.littlestreamsoftware.com/issues/3504
- timesheet_plugin : https://projects.littlestreamsoftware.com/issues/3503
- stuff_to_do : https://projects.littlestreamsoftware.com/issues/3501
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Ricardo Machado over 14 years ago
Hi,
I have this problem on Google Docs Plugin.
Enumeration.get_values('DCAT') should be changed to what?
Thanks in advance,
Ricardo Machado
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Eric Davis over 14 years ago
Ricardo Machado wrote:
I have this problem on Google Docs Plugin.
Enumeration.get_values('DCAT') should be changed to what?
DocumentCategory.all
Eric Davis
RE: Enumeration API change in r2472 - undefined method 'get_values' - Added by Ricardo Machado over 14 years ago
Eric Davis wrote:
Ricardo Machado wrote:
I have this problem on Google Docs Plugin.
Enumeration.get_values('DCAT') should be changed to what?[...]
Eric Davis
It works!
Thank you!