Plugin writing issue.
Added by Najam Alvi over 15 years ago
Hi,
I recently start working on rails. I am writing a plugin for redmine,
right now I am in the start phase. I successfully got the menu display
as "custom reports" but problem starts when I click the cutom reports
menu. The error generated is:
"The page you were trying to access doesn't exist or has been removed."
mongrel (1.1.5)
mongrel_cluster (1.0.5)
mysql (2.7)
rails (2.2.2)
rake (0.8.4)
redmine 0.8.0
where as I have not much code in controller.
Controller.
def index
render :text => 'hello'
end
even I tried
def index
render :template => 'reports/index'
end
In index.rhtml
<h2>Hi from index</h2>
In init.rb I have
require 'redmine'
Redmine::Plugin.register :redmine_reports do
permission :reports, {}, :require => :member
menu :top_menu, :reports, { :controller => 'reports', :action =>
'index'}, :caption => 'Custom Reports'
end
In terminal where webrick server is running following error information
is available: (same in the log file)
Processing ReportsController#index (for 127.0.0.2 at 2009-05-19
17:14:26) [GET]
Session ID: acbd4b9697b41f837ef990b0e2e0e807
Parameters: {"action"=>"index", "controller"=>"reports"}
Rendering template within layouts/base
Rendering common/404 (404)
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 0.03096 (32 reqs/sec) | Rendering: 0.02767 (89%) | DB:
0.00105 (3%) | 404 Not Found [http://ferrari/reports]
I cant understand why it is redirected to find_project where as I didn't
use this action anywhere.
Please help me out
Thanks a lot.
Replies (8)
RE: Plugin writing issue. - Added by Andrew Chaika over 15 years ago
Najam Alvi wrote:
Rendering template within layouts/base
Rendering common/404 (404)
Filter chain halted as [:find_project] rendered_or_redirected.
The problem is in find_project method. See filter chains.
RE: Plugin writing issue. - Added by Najam Alvi over 15 years ago
Thanks for your reply.
Yes, you are right the problem is with find_project action. But, I am not calling this action then why its come into my way. As you see in my code very simple and to the point. Still googling to find solution. Can you elaborate, please.
RE: Plugin writing issue. - Added by Andrew Chaika over 15 years ago
Maybe you have line like
before_filter :find_projectin your controller?
See filter chains reference in Ruby On Rails documentation.
RE: Plugin writing issue. - Added by Najam Alvi over 15 years ago
I am thankful for your prompt replies.
That's why I ask the question on the form here is my single controller code and you will find that I didn't use before_filter :find_project
Now I am stuck, not finding the way to get it resolved.
class ReportsController < ApplicationController
unloadable
def index
render :text => "Hello from index action"
return false
end
end
Although I don't think that there is an issue within init.rb and routes.rb files.
Here is init.rb file:
require 'redmine'
Redmine::Plugin.register :redmine_reports do
permission :reports, {:reports => [:index}, :public => :true
menu :top_menu, :reports, {:controller => 'reports', :action=>'index', :project_id=>nil}, :caption => 'Custom Reports'
end
Here is routes.rb file which contains the single line:
map.root :controller => 'reports', :action => 'index'
RE: Plugin writing issue. - Added by Andrew Chaika over 15 years ago
try
skip_before_filter :find_projector see in Rails documentation how to manage action filters, how to get filter chain for method... Maybe they are inherited from something.
Attach archive with full code of your plugin and I will see what is wrong.
RE: Plugin writing issue. - Added by Najam Alvi over 15 years ago
Thanks Andrew.
I already used the skip_before_filter. Right now I am going through the documentation you mentioned.
Please find the zip file containing the complete code.
redmine_reports.zip (22.9 KB) redmine_reports.zip |
RE: Plugin writing issue. - Added by Andrew Chaika over 15 years ago
There already app\controllers\reports_controller.rb in Redmine, rename your controller to something uniq.
RE: Plugin writing issue. - Added by Najam Alvi over 15 years ago
Aha.. I am great-full to you Andrew. Problem is resolved.
Thanks for your guidance and cooperation.