dubstep
October 18, 2011, 5:26pm
#1
I have a class variable (@neo ) that that get initialized by using
something:
Graph.connect
where the connect method will initialize the variable @neo
Right now I call the Graph.connect method in any other class that
needs to have the variable initialized.
is there a way to have the variable initialized at the start of the
execution of the app, regardless of point of entry?
heshama
October 18, 2011, 5:46pm
#2
On 18 October 2011 16:25, Hesham [email protected] wrote:
is there a way to have the variable initialized at the start of the
execution of the app, regardless of point of entry?
You could specify it in a before_filter in application_controller.
Then it will get run for any action.
Colin
heshama
October 18, 2011, 5:57pm
#3
On Oct 18, 7:34pm, Colin L. [email protected] wrote:
needs to have the variable initialized.
is there a way to have the variable initialized at the start of the
execution of the app, regardless of point of entry?
You could specify it in a before_filter in application_controller.
Then it will get run for any action.
Colin
That would work, but is there a way to have it initialized for both
controllers and models at the start.
Something like the db yaml configs?
heshama
October 18, 2011, 7:34pm
#4
On Oct 18, 7:59pm, Colin L. [email protected] wrote:
That would work, but is there a way to have it initialized for both
controllers and models at the start.
Something like the db yaml configs?
What do you mean by initialised for a model?
You said that you are initialising a class variable, I assumed you
meant a controller class variable.
A model is a class as well, right? Maybe, I should explain that the
variable is actually a connection to an external rest-dd, the Graph
model is actually responsible for all interactions with the db.
Right now, I check if the connection is set and if not I set the
connection. What I would like is to have the connection set at app
start.
heshama
October 18, 2011, 6:01pm
#5
On 18 October 2011 16:43, Hesham [email protected] wrote:
where the connect method will initialize the variable @neo
Colin
That would work, but is there a way to have it initialized for both
controllers and models at the start.
Something like the db yaml configs?
What do you mean by initialised for a model?
You said that you are initialising a class variable, I assumed you
meant a controller class variable.
Colin
heshama
October 18, 2011, 7:42pm
#6
On Oct 18, 9:33pm, Hesham [email protected] wrote:
On 18 October 2011 16:43, Hesham [email protected] wrote:
model is actually responsible for all interactions with the db.
Right now, I check if the connection is set and if not I set the
connection. What I would like is to have the connection set at app
start.
The answer would be to place this inside the related environments file
config.after_initialize do
Graph.neo = Neography::Rest.new()
end