Project

General

Profile

Actions

Defect #28340

closed

Plugin Tutorial doesn't work

Added by Grigoriy Vasilchenko over 6 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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 %>


Files

plugin_tutorial.diff (11.1 KB) plugin_tutorial.diff Mizuki ISHIKAWA, 2020-04-21 06:22
plugin_tutorial.textile (13.1 KB) plugin_tutorial.textile Mizuki ISHIKAWA, 2020-04-21 06:22
application_menu.png (48.1 KB) application_menu.png Mizuki ISHIKAWA, 2020-04-21 06:22
Actions

Also available in: Atom PDF