I am new to Ruby. My application revolves around the user having a
“Customer” object and having that customer id in the session. Right now
I have a customer service which creates the customer or finds one that
has been created and adds the id to the session. However, I can’t
guarantee that the customer service will be the first one hit when my
application starts up.
So my question is, what is the best way to ensure the creation or
presence of a Customer object and customer id in the session regardless
of which service is hit.
Any help is greatly appreciated.
can you give more details. what exactly do you mean by customer
service? Is it an object a
flow? sorry maybe someone else understands but I am trying to figure
you mean by service.
Bascially “CustomerService” is a controller (customer_controller.rb)
that handles the operations concerning a Customer object in my
application. This customer object is also represented by a table in the
db. Now I have other controllers that handle other aspects of the
application, however all of them are dependent on the existence of a
Customer object/row reachable through the session.
My application frontend is done in ExtJS, so it isn’t rendered by the
usual RoR framework.
I was thinking of adding a filter to my application controller which
would verify and/or create the customer object should one not exists in
the session, but I was unsure if this was best practice or not.
If I’ve left more questions than answers please let me know.