Redmine Plugin 개발¶
1. 플러그인 생성 스크립트 실행
ruby script/rails generate redmine_plugin Polls(플러그인명)
2. 플러그인 정보를 입력
name ‘Polls plugin’
author ‘Author name’
description ‘This is a plugin for Redmine’
version ‘0.0.1’
url ‘http://example.com/path/to/plugin’
author_url ‘http://example.com/about’
3. model 작성
ruby script/rails generate redmine_plugin_model polls poll question:string yes:integer no:integer
bundle exec rake redmine:plugins:migrate RAILS_ENV=development
4. method 추가
plugins/redmine_polls/app/models/poll.rb
class Poll < ActiveRecord::Base
def vote(answer)
increment(answer == ‘yes’ ? :yes : :no)
end
end
5. Controller 작성
ruby script/rails generate redmine_plugin_controller []
ruby script/rails generate redmine_plugin_controller Polls polls index vote
6. menu 추가
init.rb 파일에 아래와 같이 추가해 준다.
project_module :polls do
permission :view_polls, :polls => :index
permission :vote_polls, :polls => :vote
end
menu :project_menu, :polls, { :controller => ‘polls’, :action => ‘index’ }, :caption => ‘Polls’, :before => :settings, :param => :project_id
routes.rb파일에 아래와 같이 추가해 준다.
Rails.application.routes.draw do
match ‘projects/:project_id/polls/:action’, :controller => ‘polls’
end