Orbjson: Rails Objects from within lib modules?

Hi and thanks up front for your time.

(Warning: I am a NOOB to Rails and Ruby - but a quick study.)

I have some code in the rails ‘lib’ directory I wanted to give it access
to active record methods (my models), be able to access the loggers,
helpers, etc… they are my delegates. I know this sounds reverse of he
intent of lib: Why? Two reasons

  1. I would like to pass model data back and forth via Orbjson. However
    Orbjson is doing something weird with CamelCase names in it’s registry
    (‘needle’ whatever that is). It constantly mangles the names of the
    remote class objects such that they can not be found. So if I want to
    make a call on the Rails JsonController, it becomes ‘jsonController’
    which is never found. I have no idea why Orbjson is changing the name.
    So my calls fail to any mixed case objects. Only things like Foobar work
    for Orbjson. FooBar fails as translated to fooBar.

  2. Even if Orbjson didn’t mess with the name, it gets an error trying to
    instantiate a controller object to make the call on. Indeed it seems to
    get a ‘require’ error on any class in the app/xxxx directories.

So it (orbjson) works fine as the example on his site shows, but the RPC
has no access to any of the Rails classes in the application (under the
app/ directory). That kind of limits it’s usefulness to ‘generic Ruby’
processing. I want to pass model objects back and forth.

I can of course marshal object on my own using established to_json
methods, and Ajax prototype objects, however Orbjson seemed like, at the
time, a clean(er) solution. Ideas?

This brings up another question: Do all of you pack your controllers
with business logic? It seems there is no ‘delegate’ layer in Rails to
decouple Rails (aka controllers) from your business process’.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs