Class: Beyond::PluginsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/beyond/plugins_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/beyond/plugins_controller.rb', line 7

def create
  tenant_name = params[:plugin].delete :tenant
  @plugin = Plugin.new(plugin_params)
  @plugin.tenant = Tenant.find_by_name(tenant_name)
  if @plugin.save
    redirect_to root_url, notice: 'You have successfully uploaded a new plugin!'
  else
    errors = @plugin.errors.messages.map { |k, v| k.to_s+' ' + v.join(' and ')+' ' }
    redirect_to root_url, alert: 'There was an error while trying to create your plugin. ' + errors.join(' ')
  end
end

#newObject



3
4
5
# File 'app/controllers/beyond/plugins_controller.rb', line 3

def new
  @plugin = Plugin.new
end

#startObject



19
20
21
22
23
24
25
26
# File 'app/controllers/beyond/plugins_controller.rb', line 19

def start
  begin
    Plugin.find(params[:id]).start
    redirect_to root_url, notice: 'Plugin started'
  rescue
    redirect_to root_url, alert: 'Error: couldn\'t start plugin'
  end
end

#stopObject



28
29
30
31
32
33
34
35
# File 'app/controllers/beyond/plugins_controller.rb', line 28

def stop
  begin
    Plugin.find(params[:id]).stop
    redirect_to root_url, notice: 'Plugin stoped'
  rescue
    redirect_to root_url, alert: 'Error: couldn\'t stop plugin'
  end
end