views:

63

answers:

2

I want to add validations, methods, etc. to a model that is defined inside a plugin. What's the best way to do this? Would it be safe to copy the model file to the app/models directory?

+1  A: 

You can always go for monkey-patching in that way you don't have to touch the actual plugin. eg.

      class YourModel
         validate_uniqueness_of :some_field
      end

this patch either you can write as plugin itself or just can be required before use.

serioys sam
+1  A: 

If the plugin is on github you may want to think about forking it and adding the changes.

Mike Breen
Monkeypatching the model is ok, but if you can spend the time to fork the plugin, that's the best way to go :)
gsmendoza