Duane Johnson
2006-Jan-02 22:05 UTC
Re: [Rails] Can Rails render pages if there is no database connected?
This is from the rails mailing list: On Jan 1, 2006, at 4:00 PM, Duane Johnson wrote:>> I thought I knew the answer to this question (''yes''), however, >> recently I''ve been trying to build an app that detects whether or >> not the administrator has correctly configured the database. I''d >> like to give instructions in the negative case. >> >> So here''s where I''m at: if the database is configured, my app runs >> wonderfully; however, if the database doesn''t exist, or if the >> database login/password is incorrect, then Rails is completely >> unresponsive. When I load any page, I get a blank white screen. >> Checking the logs (even the server output) gives nothing at all >> (not even a GET is reported in the terminal where I have Lighttpd >> running). >> >> I created a simple Rails application from scratch ("rails simple" >> at the command line) and went to the index.html page. That worked >> fine; however, the ''About your application''s environment'' link >> shows nothing but a thin yellow line. Checking the URL that it >> goes to confirms that the same thing as described above is >> occurring: no response at all. >> >> Is this expected behavior, or is there something obvious I''m doing >> wrong that''s preventing my app from running without the database? >> >> Thanks, >> >> Duane Johnson >> (canadaduane) >> http://blog.inquirylabs.com/ >> >> >> >> > > Duane- > > I have seen the exact same behavior for a few reasons. I get the > blank screen in a fresh rails app just like you describe when the > database isn''t connected or database.yml is not filled out. I also > get it if I do something in environment.rb that doesn''t work like > require a file that can''t be found. It seems like it rails kind of > gets hung trying to load its environment so no errors go to any > logs and you just get a white screen with no errors anywhere. The > same thing can happen sometimes when you have stale old sessions > in /tmp. > > I hate the empty screen, rails should have kittens when this > happens and put errors in the logs or something. It can be a > frustrating problem to debug as well. > > Anyway, I''m just confirming this behavior as I see the same thing > you do. > > > Cheers- > -Ezra ZygmuntowiczIs this happening for a reason? It seems to me that Rails should be a little more robust on its "minimum requirements" for a basic controller and view to work properly. I''d like to investigate further, so I''m looking for a little feedback first. Duane Johnson (canadaduane) http://blog.inquirylabs.com/
Michael Koziarski
2006-Jan-02 22:12 UTC
Re: Re: [Rails] Can Rails render pages if there is no database connected?
> Is this happening for a reason? It seems to me that Rails should be > a little more robust on its "minimum requirements" for a basic > controller and view to work properly. I''d like to investigate > further, so I''m looking for a little feedback first. > > Duane Johnson > (canadaduane) > http://blog.inquirylabs.com/There are several error conditions where rails does that ''blank screen'' stuff. I try to fix them as I hit them. I can''t see a valid reason for this behaviour, so perhaps investigate a patch for it? -- Cheers Koz
Duane Johnson
2006-Jan-02 23:45 UTC
Re: Can Rails render pages if there is no database connected?
On Jan 2, 2006, at 3:12 PM, Michael Koziarski wrote:>> Is this happening for a reason? It seems to me that Rails should be >> a little more robust on its "minimum requirements" for a basic >> controller and view to work properly. I''d like to investigate >> further, so I''m looking for a little feedback first. >> >> Duane Johnson >> (canadaduane) >> http://blog.inquirylabs.com/ > > There are several error conditions where rails does that ''blank > screen'' stuff. I try to fix them as I hit them. I can''t see a > valid reason for this behaviour, so perhaps investigate a patch for > it? >I''m not sure how to fix the blank screen I was getting due to having no DB connection; however, to fix the session restore blank screen mentioned by Ezra Z. line 102 of cgi_process.rb is the culprit in that case: @session = CGI::Session.new(@cgi, session_options_with_string_keys) When switching apps (usu. on a development machine where this is common) the session restore coughs and dies without a trace because models are not the same. I think this has been discovered several times in a variety of ways (at least, I remember seeing some tickets on this). In the CGI::Session rdocs it says, "If your application switches from one to the other without making sure that filenames will be different and clients still have old sessions lying around in cookies, then things will break nastily!" So I''m wondering if we need to have a unique "application id" that gets stored in the session. If such a thing existed, we could then test to make sure the session''s APP ID matches the current APP ID. Otherwise, bust an exception. I think the best place to put the unique APP ID would be in the railties code so a UUID is created whenever a new rails app is generated. Anyone have a better alternative? Duane Johnson (canadaduane) http://blog.inquirylabs.com/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
anne001
2006-Jun-22 21:34 UTC
Re: [Rails] Can Rails render pages if there is no database connected?
"Rails should be robust on its "minimum requirements" for a basic controller and view to work properly." This was January, it is June. Is there a patch? Can Rails work without a database connected? -- View this message in context: http://www.nabble.com/Re%3A--Rails--Can-Rails-render-pages-if-there-is-no-database-connected--t839739.html#a5002213 Sent from the RubyOnRails Core forum at Nabble.com.
Tim Lucas
2006-Jun-22 22:15 UTC
Re: [Rails] Can Rails render pages if there is no database connected?
On 23/06/2006, at 7:34 AM, anne001 wrote:> "Rails should be robust on its "minimum requirements" for a basic > controller > and view to work properly." > > This was January, it is June. Is there a patch? Can Rails work > without a > database connected?Umm... have you tried yourself? $ rails test_site $ cd test_site $ ./script/generate controller test index $ rm public/index.html $ ./script/server then browse to http://127.0.0.1:3000/test and voilà!> Test#index > > Find me in app/views/test/index.rhtml-- tim
anne001
2006-Jun-22 23:42 UTC
Re: [Rails] Can Rails render pages if there is no database connected?
Thanks I will try it. I tried to follow this recipee http://media.pragprog.com/titles/fr_rr/NoDatabase.pdf and I got mysql errors with ruby test/functional/my_controller_controller_test.rb Trying to follow that tutorial gave me the idea that rails really mean rails, you have to want to go from station to station. -- View this message in context: http://www.nabble.com/Re%3A--Rails--Can-Rails-render-pages-if-there-is-no-database-connected--t839739.html#a5003908 Sent from the RubyOnRails Core forum at Nabble.com.
Tim Lucas
2006-Jun-23 01:41 UTC
Re: [Rails] Can Rails render pages if there is no database connected?
On 23/06/2006, at 9:42 AM, anne001 wrote:> Thanks I will try it. > > I tried to follow this recipee > http://media.pragprog.com/titles/fr_rr/NoDatabase.pdf > and I got mysql errors with > ruby test/functional/my_controller_controller_test.rb > Trying to follow that tutorial gave me the idea that rails really mean > rails, you have to want to go from station to station.Ah yeah, unit tests are a different kettle of fish. It might be handy to make a patch that makes those DB rake tasks check included_frameworks for ActiveRecord. -- tim
Mislav Marohnić
2006-Jun-23 10:38 UTC
Re: [Rails] Can Rails render pages if there is no database connected?
Don't forget that you can tell Rails not to require certain frameworks (in this case ActiveRecord) in your environment configuration (environment.rb). The line that shows how to do that is commented with active_mailer and action_web_service as an example; just add active_record to the array. On 6/23/06, Tim Lucas <t.lucas@toolmantim.com> wrote:> > Umm... have you tried yourself? > > $ rails test_site > $ cd test_site > $ ./script/generate controller test index > $ rm public/index.html > $ ./script/server > > then browse to http://127.0.0.1:3000/test and voilà!_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core