Defect #28340

Plugin Tutorial doesn't work

Added by Grigoriy Vasilchenko over 2 years ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:-% Done:

0%

Category:Documentation
Target version:-
Resolution:Fixed Affected version:3.4.4

Description

Ruby 2.4.3
Rails 4.2.8
Redmine 3.4.4

Hello.

I tried to create plugin using step by step plugin tutorial and there were some problems. I had to make several corrections to make plugin working. Since I'm newbie to ruby, rails, redmine - there is no confidence in rightness of my adjustments.

Paragraph "Extending the project menu":
1. I replaced @polls = Poll.find(:all) with @polls = Poll.all

def index
  @project = Project.find(params[:project_id])
  @polls = Poll.find(:all) # @project.polls
end

2. After clicking 'Yes' or 'No' error page was displaying. To solve this I modified method 'vote' ('redirect_to' invocation) to:
  def vote    
    poll = Poll.find(params[:id])
    poll.vote(params[:answer])
    if poll.save
      flash[:notice] = 'Vote saved.'
    end

    redirect_to :action => 'index', :project_id => params[:project_id]
  end

and added 'project_id' parameter in 'link_to' index.html.erb:
<% @polls.each do |poll| %>
    <p>
        <%= poll.question %>?
        <%= link_to 'Yes', { :action => 'vote', :id => poll[:id], :answer => 'yes', :project_id => @project }, :method => :post %> <%= poll.yes %> /
        <%= link_to 'No', { :action => 'vote', :id => poll[:id], :answer => 'no', :project_id => @project }, :method => :post %> <%= poll.no %>
    </p>
<% end %>

plugin_tutorial.diff Magnifier (11.1 KB) Mizuki ISHIKAWA, 2020-04-21 06:22

plugin_tutorial.textile (13.1 KB) Mizuki ISHIKAWA, 2020-04-21 06:22

application_menu.png (48.1 KB) Mizuki ISHIKAWA, 2020-04-21 06:22

History

#1 Updated by Go MAEDA over 2 years ago

  • Category set to Documentation

#2 Updated by Иван Иванов over 2 years ago

  • File Otpusk-za-svoj-schet-vmesto-obyavleniya-prostoya.jpg added

#3 Updated by Go MAEDA over 2 years ago

  • File deleted (Otpusk-za-svoj-schet-vmesto-obyavleniya-prostoya.jpg)

#4 Updated by Go MAEDA over 2 years ago

  • Description updated (diff)

#5 Updated by Mizuki ISHIKAWA over 2 years ago

Thank you for sharing the results you tried.

As a result of following the tutorial I confirmed that three problems you pointed out caused an error.
And I also confirmed that it will work out by making corrections as you say.

Since find (: all) was deprecated in rails 4, you should use Poll.all.
Since the plug-in tutorial is an old tutorial written at Redmine 2.x (rails 3), I think it should be revised.

#6 Updated by Mizuki ISHIKAWA 5 months ago

I modified the plugin tutorial to work on Redmine 4.x and Redmine 3.x.
plugin_tutorial.diff is the difference between the modified document and the current plugin tutorial.

application_menu.png should be replaced with the attached image.

#7 Updated by Go MAEDA 3 months ago

Mizuki ISHIKAWA wrote:

I modified the plugin tutorial to work on Redmine 4.x and Redmine 3.x.
plugin_tutorial.diff is the difference between the modified document and the current plugin tutorial.

application_menu.png should be replaced with the attached image.

Thank you for updating the document. Could you update plugin tutorial? Please feel free to update Wiki pages. Everyone can edit pages.

#9 Updated by Go MAEDA 3 months ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Mizuki ISHIKAWA wrote:

I just updated the plugin tutorial.
https://redmine.org/projects/redmine/wiki/Plugin_Tutorial/diff?utf8=✓&version=105&version_from=104

Thank you for your great contribution.
Closing.

Also available in: Atom PDF