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?

--
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

  • Colin Law at Oct 18, 2011 at 3:35 pm

    On 18 October 2011 16:25, Hesham wrote:
    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?
    You could specify it in a before_filter in application_controller.
    Then it will get run for any action.

    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Hesham at Oct 18, 2011 at 3:43 pm

    On Oct 18, 7:34 pm, Colin Law wrote:
    On 18 October 2011 16:25, Hesham wrote:

    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?
    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?

    --
    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.
  • Colin Law at Oct 18, 2011 at 4:00 pm

    On 18 October 2011 16:43, Hesham wrote:
    On Oct 18, 7:34 pm, Colin Law wrote:
    On 18 October 2011 16:25, Hesham wrote:

    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?
    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?
    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

    --
    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.
  • Hesham at Oct 18, 2011 at 5:33 pm

    On Oct 18, 7:59 pm, Colin Law wrote:
    On 18 October 2011 16:43, Hesham wrote:










    On Oct 18, 7:34 pm, Colin Law wrote:
    On 18 October 2011 16:25, Hesham wrote:

    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?
    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?
    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.
    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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Hesham at Oct 18, 2011 at 5:41 pm

    On Oct 18, 9:33 pm, Hesham wrote:
    On Oct 18, 7:59 pm, Colin Law wrote:








    On 18 October 2011 16:43, Hesham wrote:
    On Oct 18, 7:34 pm, Colin Law wrote:
    On 18 October 2011 16:25, Hesham wrote:

    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?
    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?
    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.

    The answer would be to place this inside the related environments file

    config.after_initialize do

    Graph.neo = Neography::Rest.new()
    end





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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 18, '11 at 3:25p
activeOct 18, '11 at 5:41p
posts6
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Hesham: 4 posts Colin Law: 2 posts

People

Translate

site design / logo © 2022 Grokbase