I am not a rails developer. I am a systems engineer trying to create a simple redmine plugin that shows the contents of a backup folder. Basically the output of Dir.glob(“/path/to/folder”). I could achieve this in the irb console.
I followed the official redmine plugin tutorial. I dont need any model because i dont want to store any database. This is just a view to show the contents form the filesystem. I created a controller which automatically generated the view. I am getting a Nameerror. Pasting the code i have made for the relevant files. Please help me with making a redmine plugin that just outputs the contents of a folder to the browser. Also how do I execute certain system calls and show the outputs in the plugin?
plugin name: redmine_backups
controller: backups_controller.rb
I havent touched this file at all.
app/views/backups/index.html.erb
<h2>Backups#index</h2>
<table>
<ul>
<% @files = Dir.glob("/tmp/*") %>
<% @files.each do |f| %>
<%= f %>
<% end %>
</ul>
</table>
redmin_backups/init.rb
require 'redmine'
Redmine::Plugin.register :redmine_backups do
name 'Redmine Database Backups plugin'
author 'Author'
description 'This is a plugin for displaying database backups within Redmine'
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
menu :application_menu, :backups, { controller => 'backups', :action => :index }, :caption => 'Backups', :last => 'true'
end
The error I get is
undefined local variable or method 'controller' for #<Redmine::Plugin:0x7f28330ca2f8>
You need a colon in front of controller on the second to last line. it should read
menu :application_menu, :backups, { :controller => 'backups', :action => :index }, :caption => 'Backups', :last => 'true'so that :controller is a ruby symbol.