Forum: Ruby on Rails Production vs Development

Fabe1e6b28afc64cdbd3c071621a7565?d=identicon&s=25 BeeRich (Guest)
on 2014-01-24 17:39
(Received via mailing list)
Hi folks.  New to Rails.

Got the following coming up using Passenger:

We're sorry, but something went wrong.
If you are the application owner check the logs for more information.

Turns out mysql is barfing.  My database.yml has my local mysql using a
username and password set for all three modes (development, test, and
production).  I am not sure why this isnt being used as the log says its
using the production database.  It is currently using root, which isnt
set anywhere.

Where can I change this?

Cheers


beerich@gmail.com
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2014-01-24 17:49
(Received via mailing list)
On Fri, Jan 24, 2014 at 8:37 AM, BeeRich <beerich@gmail.com> wrote:

> Turns out mysql is barfing.

That's so sad; maybe some ginger ale and a bit of bed rest will help?

OR maybe post the actual error message/stack trace here?

> My database.yml has my local mysql using a username and password set for all
three modes (development, test, and production).  I am not sure why this isnt
being used as the log says its using the production database.  It is currently
using root, which isnt set anywhere.

That paragraph doesn't really make sense.

The main question is: can you log into your production database
using the credentials in database.yml? If so, then can you start up
a console in production mode and access the DB?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Fabe1e6b28afc64cdbd3c071621a7565?d=identicon&s=25 BeeRich (Guest)
on 2014-01-24 18:51
(Received via mailing list)
On Jan 24, 2014, at 11:48 AM, Hassan Schroeder
<hassan.schroeder@gmail.com> wrote:

>> Turns out mysql is barfing.
>
> That's so sad; maybe some ginger ale and a bit of bed rest will help?

Hey that's funny.

> OR maybe post the actual error message/stack trace here?

>> My database.yml has my local mysql using a username and password set for all
three modes (development, test, and production).  I am not sure why this isn't
being used as the log says it's using the production database.  It is currently
using root, which isn't set anywhere.
>
> That paragraph doesn't really make sense.

- I am not in production mode.  I have merely started a new project, so
it should be in development.

- The development.log has nothing in it.  Because, like I said above
where you didn't understand, it isn't posting to the development log
because it isn't using the development database, because it isn't using
the development database.  It is posting to the production database as
demonstrated by the following in the production log:

I, [2014-01-24T11:46:55.334391 #8884]  INFO -- : Started GET "/" for
127.0.0.1 at 2014-01-24 11:46:55 -0500
F, [2014-01-24T11:46:55.338134 #8884] FATAL -- :
Mysql2::Error (Unknown database 'rortest_production'):
  mysql2 (0.3.14) lib/mysql2/client.rb:67:in `connect'
  mysql2 (0.3.14) lib/mysql2/client.rb:67:in `initialize'
  activerecord (4.0.2)
lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
  activerecord (4.0.2)
lib/active_record/connection_adapters/mysql2_adapter.rb:18:in
`mysql2_connection'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in
`new_connection'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in
`checkout_new_connection'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in
`acquire_connection'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in
`block in checkout'
  /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in
`mon_synchronize'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in
`checkout'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in
`block in connection'
  /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in
`mon_synchronize'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in
`connection'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in
`retrieve_connection'
  activerecord (4.0.2) lib/active_record/connection_handling.rb:79:in
`retrieve_connection'
  activerecord (4.0.2) lib/active_record/connection_handling.rb:53:in
`connection'
  activerecord (4.0.2) lib/active_record/query_cache.rb:51:in
`restore_query_cache_settings'
  activerecord (4.0.2) lib/active_record/query_cache.rb:43:in `rescue in
call'
  activerecord (4.0.2) lib/active_record/query_cache.rb:32:in `call'
  activerecord (4.0.2)
lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in
`call'
  actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in
`block in call'
  activesupport (4.0.2) lib/active_support/callbacks.rb:373:in
`_run__3639985778722734772__call__callbacks'
  activesupport (4.0.2) lib/active_support/callbacks.rb:80:in
`run_callbacks'
  actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in
`call'
  actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in
`call'
  actionpack (4.0.2)
lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.0.2)
lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in
`block in tagged'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in
`tagged'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in
`tagged'
  railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in
`call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.2)
lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.0.2) lib/rails/engine.rb:511:in `call'
  railties (4.0.2) lib/rails/application.rb:97:in `call'
  passenger (4.0.35)
lib/phusion_passenger/rack/thread_handler_extension.rb:77:in
`process_request'
  passenger (4.0.35)
lib/phusion_passenger/request_handler/thread_handler.rb:142:in
`accept_and_process_next_request'
  passenger (4.0.35)
lib/phusion_passenger/request_handler/thread_handler.rb:110:in
`main_loop'
  passenger (4.0.35) lib/phusion_passenger/request_handler.rb:441:in
`block (3 levels) in start_threads'

As stated, it has logged the following in the production log:

Mysql2::Error (Unknown database 'rortest_production'):

There is no such thing as the production database because it hasn't been
generated.  I had to manually generate the development database.

> The main question is: can you log into your production database
> using the credentials in database.yml? If so, then can you start up
> a console in production mode and access the DB?

I can log into any current database using the credentials in
database.yml.  For all three environments, they are the same username
and password.  The manual rortest_development is the only database
that's there because it's the only one that I have made.  Regardless, as
stated above, it is looking for the production database and not the
development database.

My question is, how do I change this?  I have no clue why it's asking
for production when I'm clearly in development.



beerich@gmail.com
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2014-01-24 18:56
(Received via mailing list)
On Jan 24, 2014, at 12:50 PM, BeeRich wrote:

>
>> The main question is: can you log into your production database
>> using the credentials in database.yml? If so, then can you start up
>> a console in production mode and access the DB?
>
> I can log into any current database using the credentials in database.yml.  For
all three environments, they are the same username and password.  The manual
rortest_development is the only database that's there because it's the only one
that I have made.  Regardless, as stated above, it is looking for the production
database and not the development database.
>
> My question is, how do I change this?  I have no clue why it's asking for
production when I'm clearly in development.


If you're clearly in development, why are you hitting passenger? What
does your passenger configuration (in Apache or Nginx) look like? Did
you set an environment flag explicitly to development? If not, I believe
that passenger always defaults to production.

Walter
Fabe1e6b28afc64cdbd3c071621a7565?d=identicon&s=25 BeeRich (Guest)
on 2014-01-24 19:01
(Received via mailing list)
On Jan 24, 2014, at 12:54 PM, Walter Lee Davis <waltd@wdstudio.com>
wrote:

> If you're clearly in development, why are you hitting passenger? What does your
passenger configuration (in Apache or Nginx) look like? Did you set an 
environment
flag explicitly to development? If not, I believe that passenger always defaults
to production.

I have no clue.  I installed Passenger to use Apache instead of WEBrick.
Heres what I have:

LoadModule passenger_module
/Library/Ruby/Gems/2.0.0/gems/passenger-4.0.35/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
 PassengerRoot /Library/Ruby/Gems/2.0.0/gems/passenger-4.0.35
 PassengerDefaultRuby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
</IfModule>

In the VHost directive:
AllowOverride all
Options -MultiViews

Other than that I dont know where to find other Passenger parameters.
Is there no way to use Passenger for a local development environment?

Cheers

beerich@gmail.com
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2014-01-24 19:07
(Received via mailing list)
On Jan 24, 2014, at 12:59 PM, BeeRich wrote:

> PassengerDefaultRuby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
> </IfModule>
>
> In the VHost directive:
> AllowOverride all
> Options -MultiViews
>
> Other than that I don't know where to find other Passenger parameters.  Is there
no way to use Passenger for a local development environment?

Sure. You just need to read through the passenger docs to find the
proper flag to add inside the <IfModule mod_passenger.c> block. It's
something simple like `RailsEnvironment development` or something like
that.

Walter
Fabe1e6b28afc64cdbd3c071621a7565?d=identicon&s=25 BeeRich (Guest)
on 2014-01-24 21:45
(Received via mailing list)
OK, with some reading I think I'll uninstall Passenger until I have some
time to dedicate time to it.  I thought it was a simple solution for
apache.

Thanks for the heads up.


On Jan 24, 2014, at 1:05 PM, Walter Lee Davis <waltd@wdstudio.com>
wrote:

> Sure. You just need to read through the passenger docs to find the proper flag
to add inside the <IfModule mod_passenger.c> block. It's something simple like
`RailsEnvironment development` or something like that.




beerich@gmail.com
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2014-01-25 14:16
(Received via mailing list)
On Friday, January 24, 2014 7:05:43 PM UTC+1, Walter Lee Davis wrote:

> >
>
> > Other than that I don’t know where to find other Passenger parameters.  Is
there no way to use Passenger for a local development environment?
>
>
>
> Sure. You just need to read through the passenger docs to find the proper flag
to add inside the <IfModule mod_passenger.c> block. It's something simple like
`RailsEnvironment development` or something like that.
>
>

It's RackEnv (which is an alias for  PassengerAppEnv) and it defaults to
production.
I used passenger in development for a long time but I switched to pow.cx
a while back - partly because i didn't have to keep adding vhosts for
new apps

Fred
Fabe1e6b28afc64cdbd3c071621a7565?d=identicon&s=25 BeeRich (Guest)
on 2014-01-25 15:35
(Received via mailing list)
Thats good information.  Thanks for that.  I got Passenger working but
as you have indicated, managing vhosts would be much easier with a
single local domain reference.  I will check it out.

Cheers





On Jan 25, 2014, at 8:14 AM, Frederick Cheung
<frederick.cheung@gmail.com> wrote:

> It's RackEnv (which is an alias for  PassengerAppEnv) and it defaults to
production.
> I used passenger in development for a long time but I switched to pow.cx a while
back - partly because i didn't have to keep adding vhosts for new apps
>
> Fred



beerich@gmail.com
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.