@@ -14,9 +14,9 @@ class Plugin
1414 property :active , Boolean
1515
1616 before :save , :download
17- after :save , :install
18- after :save , :set_create_activity
19- after :save , :set_update_activity
17+ after :create , :install
18+ after :create , :set_create_activity
19+ after :update , :set_update_activity
2020 after :destroy , :remove
2121
2222 class << self
@@ -52,23 +52,22 @@ def download
5252 ##
5353 # This loads and installs the plugin
5454 def install
55- if new_record?
56- # Ensure we don't have any errors while saving already
57- if self . errors . empty?
58- begin
59- # Load the plugin
60- self . load
61- # Also, if there is an "install.rb" script present, run that to setup anything the plugin needs (database tables etc)
62- require File . join ( self . path , "install.rb" ) if File . exists? ( File . join ( self . path , "install.rb" ) )
63- rescue Exception => err
64- # If we have an issue installing, lets destroy the plugin to rollback, and put an error on the object so it displays on the form
65- self . destroy
66- self . errors . add "Error installing plugin: #{ err . message } "
67- end
68- else
69- # If we do, destroy the plugin to rollback, and then the form will display the errors
55+ # Ensure we don't have any errors while saving already
56+ if self . errors . empty?
57+ begin
58+ # Load the plugin
59+ self . load
60+ # Also, if there is an "install.rb" script present, run that to setup anything the plugin needs (database tables etc)
61+ Merb . logger . debug! ( "Trying to autoload install.rb of plugin (#{ File . join ( self . path , "install.rb" ) } )" )
62+ require File . join ( self . path , "install.rb" ) if File . exists? ( File . join ( self . path , "install.rb" ) )
63+ rescue Exception => err
64+ # If we have an issue installing, lets destroy the plugin to rollback, and put an error on the object so it displays on the form
7065 self . destroy
66+ self . errors . add "Error installing plugin: #{ err . message } "
7167 end
68+ else
69+ # If we do, destroy the plugin to rollback, and then the form will display the errors
70+ self . destroy
7271 end
7372 end
7473
0 commit comments