How to use methods from other plugins?
Added by Robert W. about 14 years ago
Hello everyone,
For example I like to use a method from stuff_to_do plugin for work_time plugin. Is this even possible?
Replies (4)
RE: How to use methods from other plugins?
-
Added by Robert W. about 14 years ago
Thank you.
I added a button in work_time to get all tickets which are assigned to myself. After that I tried to use the "doing_now" method from stuff_to_do plugin to determine the tickets which I'am currently working on. On click I got a undefined method error "doing_now". My ruby knowledge is non-existent or very low.
Could someone give me a hint how to realize that?
RE: How to use methods from other plugins?
-
Added by Robert W. about 14 years ago
This is what I get:
NoMethodError in Work_time#ajax_select_ticket
Showing vendor/plugins/redmine_work_time/app/views/work_time/ajax_select_ticket.html.erb where line #4 raised:
undefined method `doing_now' for :StuffToDo:Symbol
Extracted source (around line #4):
1: <form style="font-size:14px;">
2: <%
3: issues = Issue.find(:all, :order=>"id DESC", :conditions =>
4: ["assigned_to_id=:ati",{:ati=>params[:StuffToDo.doing_now(user user)]}])
5: issues.each do |issue|
6: if issue.closed? then
7: next if !params.key?(:all);
RAILS_ROOT: /opt/redmine/redmine-1.0.0
Application Trace | Framework Trace | Full Trace
/opt/redmine/redmine-1.0.0/vendor/plugins/redmine_work_time/app/views/work_time/ajax_select_ticket.html.erb:4:in `_run_erb_vendor47plugins47redmine_work_time47app47views47work_time47ajax_select_ticket46html46erb'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/base.rb:306:in `with_template'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/template.rb:205:in `render_template'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/base.rb:265:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1250:in `render_for_file'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:987:in `render_without_benchmark'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
/opt/redmine/redmine-1.0.0/vendor/plugins/redmine_work_time/app/controllers/work_time_controller.rb:81:in `ajax_select_ticket'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/flash.rb:146:in `perform_action'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process_without_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:437:in `call'
/opt/redmine/redmine-1.0.0/vendor/plugins/redmine_work_time/app/views/work_time/ajax_select_ticket.html.erb:4:in `_run_erb_vendor47plugins47redmine_work_time47app47views47work_time47ajax_select_ticket46html46erb'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/base.rb:306:in `with_template'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/template.rb:205:in `render_template'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/base.rb:265:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1250:in `render_for_file'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:987:in `render_without_benchmark'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
/opt/redmine/redmine-1.0.0/vendor/plugins/redmine_work_time/app/controllers/work_time_controller.rb:81:in `ajax_select_ticket'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/flash.rb:146:in `perform_action'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process_without_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:437:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:87:in `dispatch'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:121:in `_call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:130
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:93:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:158:in `each'
/usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:285:in `new'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:268:in `new'
/usr/lib/ruby/1.8/mongrel.rb:268:in `run'
/opt/redmine/redmine-1.0.0/vendor/rails/railties/lib/commands/server.rb:111
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
/opt/redmine/redmine-1.0.0/vendor/plugins/redmine_work_time/app/views/work_time/ajax_select_ticket.html.erb:4:in `_run_erb_vendor47plugins47redmine_work_time47app47views47work_time47ajax_select_ticket46html46erb'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:34:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/base.rb:306:in `with_template'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/renderable.rb:30:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/template.rb:205:in `render_template'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_view/base.rb:265:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1250:in `render_for_file'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:987:in `render_without_benchmark'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
/opt/redmine/redmine-1.0.0/vendor/plugins/redmine_work_time/app/controllers/work_time_controller.rb:81:in `ajax_select_ticket'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/redmine/redmine-1.0.0/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/flash.rb:146:in `perform_action'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `send'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process_without_filters'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:437:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:87:in `dispatch'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:121:in `_call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:130
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:93:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/opt/redmine/redmine-1.0.0/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'
/usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:158:in `each'
/usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:285:in `new'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:268:in `new'
/usr/lib/ruby/1.8/mongrel.rb:268:in `run'
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run'
/opt/redmine/redmine-1.0.0/vendor/rails/railties/lib/commands/server.rb:111
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Request
Parameters:
{"usr"=>"1"}
Show session dump
Response
Headers:
{"Content-Type"=>"text/html",
"Cache-Control"=>"no-cache"}
RE: How to use methods from other plugins?
-
Added by Felix Schäfer about 14 years ago
I'm not sure I understand what you are trying to do, but:
- Having that sort of logic (Issue.find and so on) in the view is a bad idea (and bad rails design at least, bad MVC probably too)
params
is a hash containing parameters pertaining to the current request, I'm not sure what you are trying to get out of that- "Things" beginning with a
:
are symbols (names or references if you will), they don't carry any information other than their name on their own - If there is a model called StuffToDo with a method doing_now taking a user as a parameter, then
StuffToDo.doing_now(@user)
is the right way to call it.
All in all, I think you will need a better understanding of ruby and rails to achieve what you are trying to do.