Skip to content
Browse files

Didn't quite work as I'd hoped as the plugin model doesn't expose the…

… created_at/updated_at fields that a model usually would. Will have to think a little more outside the box
  • Loading branch information...
1 parent 3c9c6c8 commit f56431f3243568e1f8480c590d610296f67f81aa @fujin fujin committed Jun 23, 2008
Showing with 13 additions and 17 deletions.
  1. +13 −17 app/models/plugin.rb
View
30 app/models/plugin.rb
@@ -52,26 +52,22 @@ def download
##
# This loads and installs the plugin
def install
- if created_on == Date.today and touched_on == Date.today and new_record? == false and updated_on == nil
- # Ensure we don't have any errors while saving already
- if self.errors.empty?
- begin
- # Load the plugin
- self.load
- # Also, if there is an "install.rb" script present, run that to setup anything the plugin needs (database tables etc)
- Merb.logger.debug!("Trying to autoload install.rb of plugin (#{File.join(self.path, "install.rb")})")
- require File.join(self.path, "install.rb") if File.exists?(File.join(self.path, "install.rb"))
- rescue Exception => err
- # 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
- self.destroy
- self.errors.add "Error installing plugin: #{err.message}"
- end
- else
- # If we do, destroy the plugin to rollback, and then the form will display the errors
+ # Ensure we don't have any errors while saving already
+ if self.errors.empty?
+ begin
+ # Load the plugin
+ self.load
+ # Also, if there is an "install.rb" script present, run that to setup anything the plugin needs (database tables etc)
+ Merb.logger.debug!("Trying to autoload install.rb of plugin (#{File.join(self.path, "install.rb")})")
+ require File.join(self.path, "install.rb") if File.exists?(File.join(self.path, "install.rb"))
+ rescue Exception => err
+ # 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
self.destroy
+ self.errors.add "Error installing plugin: #{err.message}"
end
else
- Merb.logger.debug!("Not reinstalling already installed plugin")
+ # If we do, destroy the plugin to rollback, and then the form will display the errors
+ self.destroy
end
end

0 comments on commit f56431f

Please sign in to comment.
Something went wrong with that request. Please try again.