Plugin dev tutorial (Polls) : issue

Added by Gui MOC over 7 years ago

Dear All,

i tried to follow the "Polls" tutorial for creating plugin.
while the plugin is set as a "project_menu" it is well added as a new tab, but i get an error after voting : it do not launch the 'index' (the vote is done). I do understand that there is an information missing about the project identifier.

if i launch to the polls page using the project menu tab "Polls" the URL is :
http://localhost:8080/redmine/polls?*project_id=prj2*
this is because the menu configuration is :
_ menu :project_menu, :polls, {:controller => 'polls', :action => 'index'}, :caption => 'Polls', :last=> true, :param => :project_id_
:param => :project_id is used by the controllers' action 'index'.
but when 'index' is called from the action 'vote' by a r_edirect_to_, how the project_id is given to 'index' ?

i'm brand new in ruby and RoN so i'm learing it with redmine ...

so i tried this :

in the view :
<%= link_to 'No', {:action => 'vote', :id => poll[:id], :answer => 'no', :project_id => @project[:identifier]}, :method => :post > (<= poll[:no] %>)

in the controller :
redirect_to :action => 'index' , :project_id => params[:project_id]

It works ...

But can one of yours explain me if it's the good way ?
Or is there one information missing in the tutorial ?

I thank you in advance

Guillaume