Rails object lifecycle - cross-transaction objects creation and destroy

472 views Asked by At

Is there a way to have objects on a Rails app that conserve their state between HTTP transactions?

For example, can I initialize a Net::LDAP connection somewhere and use it to retrieve data only restarting it on lost connection?

1

There are 1 answers

0
Dan Grahn On BEST ANSWER

You can use class variables.

class Connection
  def initialize
    @@connection ||= # Start connectio
  end
end