On Thu, Oct 30, 2008 at 2:45 PM, James Adam <[EMAIL PROTECTED]> wrote: > On 30 Oct 2008, at 13:35, Raphael Bauduin wrote: > >> Hi, >> >> I have an Instance model in my application, to which I want to add a >> has_many :web_file_attachment from the plugin. >> I tried putting this in my plugin's app/model/instance.rb : >> class Instance < ActiveRecord::Base >> has_many :web_file_attachments , :dependent => :destroy >> end >> >> but it doesn't seem to work. > > The engines plugin doesn't mix model code (yet), so it's unlikely that your > plugin model is being loaded. > > A better way to do this would be to add a 'macro' method to > ActiveRecord::Base, which you can then call in your main application model, > along the lines of > > app/models/instance.rb > > class Instance < ActiveRecord::Base > # other stuff... > has_web_file_attachments > end > > This would give you more flexibility, I think.
Yes, but I'm looking at engines to be able to add this without touching the main app. Actually I'm building a new datatype for dedomenon.org , and it would be great if it was possible without touching the main application's code: just install the engine and you're done. Isn't there a way to achieve this? Thanks for your help! Raph > > The main reason why your current setup doesn't work, is that the engines > plugin isn't loading your plugin model. > > James > _______________________________________________ > Engine-Users mailing list > [email protected] > http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org > -- Web database: http://www.myowndb.com Free Software Developers Meeting: http://www.fosdem.org _______________________________________________ Engine-Users mailing list [email protected] http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org
