Redmine plugin tutorial issues for 1.3.X
Added by Sandun Weerasinghe about 9 years ago
Hi All,
I was following redmine plugin tutorial on http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial .
I have followed up to the point 'Extending the project menu'. So I my controller is like followings,
class PollsController < ApplicationController
unloadable
def index
@project = Project.find(params[:project_id])
@polls = Poll.find(:all) # @project.polls
end
def vote
poll = Poll.find(params[:id])
poll.vote(params[:answer])
if poll.save
flash[:notice] = 'Vote saved.'
end
redirect_to :action => 'index'
end
end
But when I click on the polls menu item on project. I can see following error on the logs.
Started GET "/polls?project_id=project1" for 127.0.0.1 at 2015-10-27 11:48:48 +0530
Processing by PollsController#index as HTML
Parameters: {"project_id"=>"project1"}
Current user: admin (id=1)
Completed 404 Not Found in 12ms (ActiveRecord: 4.0ms)
ActiveRecord::RecordNotFound (Couldn't find Poll with 'id'=all):
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
So I changed controller to following,
class PollsController < ApplicationController
unloadable
def index
@project = Project.find(params[:project_id])
@polls = Poll.all
end
def vote
....
end
end
Then that error is resolved. But when voting then I have following error.
Started GET "/polls" for ::1 at 2015-10-27 11:47:33 +0530
Processing by PollsController#index as HTML
Current user: admin (id=1)
Completed 404 Not Found in 4ms (ActiveRecord: 0.0ms)
ActiveRecord::RecordNotFound (Couldn't find Project with 'id'=):
app/models/project.rb:303:in `find'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Then I did following changes on controller.
class PollsController < ApplicationController
unloadable
def index
@project = Project.find_by_identifier(params[:project_id])
@polls = Poll.all
end
Then I was able to resolve that issue as well. But I am not sure that is the correct fix. So now I can vote as well.
But when voting default project menu is not displaying. So it looks like the attached picture.
Could you guys let me know the changes I did are correct and how I can get the default project menu?
!!
Regards,
Sandun
Capture.PNG (9.01 KB) Capture.PNG |