On Thu, Oct 30, 2008 at 2:59 PM, James Adam <[EMAIL PROTECTED]> wrote:
> On 30 Oct 2008, at 13:56, Raphael Bauduin wrote:
>>
>> 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!
>
> In this case, you'll need to ensure that the main application instance.rb
> model is loaded before you reopen the class in your plugin. I would probably
> do something along the lines of
>
> my_plugin/init.rb
>
> require 'instance_extensions'
>
> my_plugin/lib/instance_extensions.rb
>
> require 'instance' # maybe raise an error here if it's missing in the main
> app
> Instance.class_eval do
> has_many :web_file_attachments # ....
> end
>
> Hope that helps,
It's going in the right direction, but it's not working yet as I get
this error when starting the application:
=> Booting WEBrick...
/home/rb/dev/dedomenon/vendor/rails/activerecord/lib/active_record/associations.rb:1273:in
`before_destroy': wrong number of arguments (1 for 0) (ArgumentError)
from
/home/rb/dev/dedomenon/vendor/rails/activerecord/lib/active_record/associations.rb:1273:in
`configure_dependency_for_has_many'
from
/home/rb/dev/dedomenon/vendor/rails/activerecord/lib/active_record/associations.rb:711:in
`has_many'
from
/home/rb/dev/dedomenon/vendor/plugins/web_file_attachment/lib/instance_extensions.rb:3
from
/home/rb/dev/dedomenon/vendor/plugins/web_file_attachment/lib/instance_extensions.rb:2:in
`class_eval'
from
/home/rb/dev/dedomenon/vendor/plugins/web_file_attachment/lib/instance_extensions.rb:2
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from
/home/rb/dev/dedomenon/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in
`require'
... 26 levels...
from
/home/rb/dev/dedomenon/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in
`require'
from
/home/rb/dev/dedomenon/vendor/rails/railties/lib/commands/server.rb:39
from ./script/server:3:in `require'
from ./script/server:3
The line causing the problem is
has_many :web_file_attachments , :dependent => :destroy
This exact same line put in the Instance class of the application works fine.
Any hints?
Thanks!
Raph
>
> 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