Wins Lin
2013-Apr-14 22:26 UTC
How to initialize variables automatically on application bootstrap?
How to set some variables on bootstap? I need a few variables to be initialized with default values every request. For example in ZF there is a class Bootstrap whose methods are called automatically every request. Is there something similar in Rails? -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists
2013-Apr-14 23:31 UTC
Re: How to initialize variables automatically on application bootstrap?
On Sun, Apr 14, 2013 at 5:26 PM, Wins Lin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> How to set some variables on bootstap? I need a few variables to be > initialized with default values every request. For example in ZF there > is a class Bootstrap whose methods are called automatically every > request. Is there something similar in Rails?Do these need to be initialized before configuration? If not, you can put them in config/initializers/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists
2013-Apr-14 23:35 UTC
Re: How to initialize variables automatically on application bootstrap?
On Sun, Apr 14, 2013 at 6:31 PM, tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Apr 14, 2013 at 5:26 PM, Wins Lin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> How to set some variables on bootstap? I need a few variables to be >> initialized with default values every request. For example in ZF there >> is a class Bootstrap whose methods are called automatically every >> request. Is there something similar in Rails? > > Do these need to be initialized before configuration? If not, you can > put them in config/initializers/Never mind, I mis-read what you wrote. ZF I''m assuming is Zend Framework, aka, PHP? Which works nothing like Rails, btw, as you are essentially restarting the entire application with every request in PHP. The Rails application is not brought up and shut down for every request. It lives in a long running process. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Ricardo Franco
2013-Apr-14 23:41 UTC
Re: How to initialize variables automatically on application bootstrap?
Maybe hardcoding them in a before_filter on ApplicationController... Which kind of variables are you talking about? Where do you plan to use them? 2013/4/14 tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> On Sun, Apr 14, 2013 at 6:31 PM, tamouse mailing lists > <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Sun, Apr 14, 2013 at 5:26 PM, Wins Lin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> How to set some variables on bootstap? I need a few variables to be > >> initialized with default values every request. For example in ZF there > >> is a class Bootstrap whose methods are called automatically every > >> request. Is there something similar in Rails? > > > > Do these need to be initialized before configuration? If not, you can > > put them in config/initializers/ > > Never mind, I mis-read what you wrote. > > ZF I''m assuming is Zend Framework, aka, PHP? Which works nothing like > Rails, btw, as you are essentially restarting the entire application > with every request in PHP. > > The Rails application is not brought up and shut down for every > request. It lives in a long running process. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Ricardo Franco Andrade ( Web | Desktop | Game ) Developer email: ricardo.krieg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org phone: +55 (86) 9436 0830 linkedin: http://www.linkedin.com/pub/ricardo-franco/61/2b0/857 skype: ricardo.krieg github: https://github.com/ricardokrieg twitter: twitter.com/ricardokrieg facebooK: https://www.facebook.com/krieg.ricardo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Wins Lin
2013-Apr-15 12:08 UTC
Re: How to initialize variables automatically on application bootstrap?
Ricardo Franco wrote in post #1105627:> Maybe hardcoding them in a before_filter on ApplicationController... > > Which kind of variables are you talking about? Where do you plan to use > them?Yes, "before_filter" works just fine. Yet do not understand the details how it works but it works :) I want to have a predefined variable in every method of my controllers. It is @isAuth = false. I did like this in "application_controller.rb": before_filter :setAuth def setAuth @isAuth = false end Thanks. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Wins Lin
2013-Apr-15 12:10 UTC
Re: How to initialize variables automatically on application bootstrap?
tamouse mailing lists wrote in post #1105626:> On Sun, Apr 14, 2013 at 6:31 PM, tamouse mailing lists > <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Never mind, I mis-read what you wrote. > > ZF I''m assuming is Zend Framework, aka, PHP? Which works nothing like > Rails, btw, as you are essentially restarting the entire application > with every request in PHP.Yes, I meant Zend Framework.> The Rails application is not brought up and shut down for every > request. It lives in a long running process.But how it can be? HTTP is a stateless protocol. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Walter Lee Davis
2013-Apr-15 12:15 UTC
Re: How to initialize variables automatically on application bootstrap?
On Apr 15, 2013, at 8:10 AM, Wins Lin wrote:> tamouse mailing lists wrote in post #1105626: >> On Sun, Apr 14, 2013 at 6:31 PM, tamouse mailing lists >> <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Never mind, I mis-read what you wrote. >> >> ZF I''m assuming is Zend Framework, aka, PHP? Which works nothing like >> Rails, btw, as you are essentially restarting the entire application >> with every request in PHP. > > Yes, I meant Zend Framework. > >> The Rails application is not brought up and shut down for every >> request. It lives in a long running process. > > But how it can be? HTTP is a stateless protocol.Right, but Rails implements a full application server within its long-running process, and maintains a session cookie to track individual users across multiple request loops. PHP is just beginning to be able to do this sort of thing, I think. Isn''t there a server in the latest beta or alpha? Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists
2013-Apr-15 13:18 UTC
Re: Re: How to initialize variables automatically on application bootstrap?
On Mon, Apr 15, 2013 at 7:10 AM, Wins Lin <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> tamouse mailing lists wrote in post #1105626: >> On Sun, Apr 14, 2013 at 6:31 PM, tamouse mailing lists >> <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> The Rails application is not brought up and shut down for every >> request. It lives in a long running process. > > But how it can be? HTTP is a stateless protocol.It is quite possible to build a statefull protocol on top of a stateless one. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.