use project.identifier as variable in redmine
Added by Medhamsh V almost 12 years ago
In our redmine setup, corresponding to the project.identifier (not :project_id) we have folders in another server and the developers store the mysql database dumps related to their project. I am trying to write a plugin which just shows the list of all the database dumps.
For this initially I tried using net/ssh and then the plugin logs into the another server where the db dumps are located and does an ls. I show the ls output in an unordered list in the plugin's view. For this i should send the project.identifier as the argument to ls to get the list of dumps particular to that project. Could not figure out how to send local variables via Net::SSH.
Then I changed my idea of using net/ssh and now simply executing a local script which does an ssh and ls. Now I want to use project.identifier again as an argument. How can i pass the value of project.identifier as an argument to the command in system call?
This is my controller.
require 'rubygems' require 'net/ssh' class BackupsController < ApplicationController helper :projects unloadable def index #host = '192.168.122.245' #user = 'root' #Net::SSH.start( host, user ) do |ssh| #@result = ssh.exec!('dumplist website') #end @identifier = "#{project.identifier}" @result = %x[dumpshow @identifier] end end
dumpshow is my script which does an ssh runs ls $1 . I want to send project.identifier as $1
With the above script I am getting the following error.
NameError (undefined local variable or method 'project' for #<BackupsController:0x7ff5b4a756a0>):
Replies (2)
RE: use project.identifier as variable in redmine - Added by Medhamsh V almost 12 years ago
I wanna put it the other way. How to use redmine core's variables in the controllers of custom plugins we write?
RE: use project.identifier as variable in redmine - Added by Harry Garrood almost 12 years ago
Am I right in thinking that the backup resources want to be nested within a project, like this?
GET /projects/:project_id/backups
If that's the case, you should add a route:
# routes.rb
resources :backups,
:path => '/projects/:project_id/release_notes'
and then your controller has access to the project id in params:
# backups_controller.rb
project = Project.find(params[:project_id])
You should read the plugin tutorial if you're still confused.