Overriding models?

1 view
Skip to first unread message

Michael

unread,
Feb 19, 2010, 4:08:08 PM2/19/10
to subs...@googlegroups.com
Hi Seth and Roger,

Thanks for creating this project and keeping it alive and being active here on the mailing list. I've enjoyed developing with keeping the engine as is and doing my customization in my App directory.

I have a question regarding how to override a whole model and not sure of the way to do it. I intend to change the way I register customers so instead of having validates_uniqueness_of email I want to do it on username. I tried to do this by just copying order_user.rb to app/models and making the modifications without adding "require_dependency RAILS_ROOT + ..." to the top of the file. However this causes a Stack level too deep error. Is there another way I should be doing this?

BTW The username, firstname and lastname of the order_user table doesn't seem to be used in the current app. How come?

Best Regards

Michael Carøe Andersen

seth b

unread,
Feb 20, 2010, 2:15:58 AM2/20/10
to subs...@googlegroups.com
I think you should be OK just putting your own class in the app/models
directory but I haven't done that for awhile. Can you pastie your
code? (http://pastie.org)

I removed username from the order_user table because it wasn't being
utilized in the code at all.

--------------------
http://subimage.com
http://twitter.com/subimage

> --
> You received this message because you are subscribed to the Google Groups
> "substruct" group.
> To post to this group, send email to subs...@googlegroups.com.
> To unsubscribe from this group, send email to
> substruct+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/substruct?hl=en.
>

Roger Pack

unread,
Feb 20, 2010, 3:48:15 PM2/20/10
to subs...@googlegroups.com
> I think you should be OK just putting your own class in the app/models
> directory but I haven't done that for awhile. Can you pastie your
> code? (http://pastie.org)

Yeah what's the backtrace?
-r

Michael

unread,
Feb 22, 2010, 10:53:57 AM2/22/10
to subs...@googlegroups.com
Ok, Seth my codebase is from revision 201 (from 24/01/10) before you removed username. However it will be useful for me and I don't need the affiliate stuff so I was intending on staying on that revision. 

Well basically I have just copied the whole order_user.rb model over to my apps/model and that gives me this error when I try to checkout:

"Something went bad when trying to checkout...
OrderUser(#46534020) expected, got OrderUser(#47217110)"

The whole backtrace is here:

Best Regards

Michael Carøe Andersen


Roger Pack

unread,
Feb 22, 2010, 12:15:22 PM2/22/10
to subs...@googlegroups.com
> "Something went bad when trying to checkout...
> OrderUser(#46534020) expected, got OrderUser(#47217110)"
> The whole backtrace is here:
> http://pastie.org/836915

Historically this has meant "it is using an old version of OrderUser
because plugins don't get reloaded right" [1]
http://hervalicio.us/blog/2007/05/07/user-expected-got-user/


my typical work around is to run it in production mode, but that
wouldn't, of course, explain *why* it appears to be loading your
order_user file from both the plugin and models folder.

To see "when" it is loading both of them you could puts a
"puts caller"
at the top of each file.

GL.
-r

Michael

unread,
Feb 24, 2010, 8:20:14 AM2/24/10
to subs...@googlegroups.com
Thanks for the heads up, Roger. 

I ended up working around the problem. Could not figure out what caused the problem and the "puts caller" did not seem to work for me.
Reply all
Reply to author
Forward
0 new messages