Hello Everyone,
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.

--
Posted via http://www.ruby-forum.com/.

--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Gerbdla at Feb 8, 2012 at 7:01 pm
    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
    out what
    you mean by service.
    On Feb 8, 10:42 am, Jonah Jameson wrote:
    Hello Everyone,
    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.

    --
    Posted viahttp://www.ruby-forum.com/.
    --
    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Jonah Jameson at Feb 8, 2012 at 7:39 pm
    Thanks gerbdla,
    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.

    --
    Posted via http://www.ruby-forum.com/.

    --
    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 8, '12 at 6:43p
activeFeb 8, '12 at 7:39p
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Jonah Jameson: 2 posts Gerbdla: 1 post

People

Translate

site design / logo © 2022 Grokbase