Ruby on Rails Monday, October 29, 2012

On 29 October 2012 16:23, PierreW <wamrewam@googlemail.com> wrote:
> Hi Colin, Bill
>
> Here is what we are doing:
>
> - we pass to our "service" the Model objects (we Marshal.dump them in
> the main app, enqueue them, and the service Marshal.load them) instead
> of their unique ID.
> - in the service, we just need to access some of the models' methods.
> We know these methods don't need a DB connection.

Do you need knowledge of any of the attributes of the object that are
database fields? If so then you need a connection to the db as it is
by looking in the db that the model knows what its fields are and
hence the attribute names.

>
> The reason we have it setup like this is initially, we were running
> these tasks in threads within a background job (threads caused a bunch
> of issues when we were using the DB, so we made sure what we passed to
> the threads would never use the DB).

As Bill has suggested in his reply, you could extract the methods that
do not need the database (if they really do not) out into helpers.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment