Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

ruby on rails - Accessing Redmine controllers through a plugin

I've already asked the question on the Redmine official website but I didn't get any answer, maybe I'll have more chance here.

I'm working on a project and I try to improve an existing plugin for Redmine by adding some features to it to allow the user to upload his Dropbox files in the Redmine documents with a simple form. Redmine already has this possibilty so I would like to use the controller and methods already defined in the Redmine source code.

I have the following code in one of my plugin views:

<% html_title "Reddrop - Sync" %>
<h2>Synchronisation page</h2>
<p>Please choose your file</p>
<%= form_tag({:controller => "documents", :action => "add_attachment", :id => @document},    :multipart => true) do %>
<%= file_field_tag 'attachments[dummy][file]', :id => nil, :multiple => true, :onchange => "addInputFiles(this)" %>
<%= submit_tag(value = "Sync this file with Redmine") %>
<% end %>

I'm calling the "documents" controller and the add_attachment method which are defined in the Redmine source code. When I submit my form I get the following error:

ActionController::RoutingError (No route matches {:controller=>"documents", :action=>"add_attachment", :id=>nil}):

Is it possible to call these controllers/methods through a plugin if they are defined in the Redmine source code?

If yes, maybe could you give some advice to how configure my routes?

question from:https://stackoverflow.com/questions/22247117/accessing-redmine-controllers-through-a-plugin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

See here :id => @document
@document is the variable that contains nil however this should contain some id (like 1,2 or whatever) of required record check it in your controller and once you will fix this issue sure this error will be resolved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...