Topic: Config Production Rails App to Run Locally for Development

Hello, all. I'm an experienced developer in ASP.Net and C#, with very little Rails experience...a definite n00b.  A real-world opportunity to learn some Rails has fallen in my lap and though I welcome it, I'm feeling a bit lost in the woods at the moment.

I've been asked by a new client to provide some minor changes to a production Rails app. Either the original developer has abandoned the client, or the client had a falling out with them a couple of years back. I'm not sure which is the true case, but regardless, the job falls on me to make the changes and get the app deployed on the production server.

At this point I'm not even sure what questions to ask, but here is what I have learned about the app and production deployment so far:

  • Rails 2.3.2 according to the environment.rb file. I've installed that on my Windows box after installing Ruby 1.8.7 and Ruby Gems 1.8.15. I believe all of this installed without issue.

  • I have all the production files and production DB (MySQL) downloaded from Slicehost.

  • When I tried to start the rails server (rails s) from within the root of the local site, I got an error about various missing dependencies related to something called ActiveSupport. (Sorry...don't have the specific errors as I am posting this from my day-job PC).

  • I know nothing about "Capistrano" other than that it is a tool used with Git to deploy sites, but there is a "Capify" file in the root of the site. I'm hoping that that will make my eventual deployment easier.

The app is basically a simple CMS and I have been asked to add a an additional checkbox to one of the backend pages. I have identified which view needs to be changed and the associated helper file. I know that to make those changes work I need to create a migration to add this additional column to the database...I know this is the case because this new checkbox is related to the start of a new year and I can see the migration .rb script that the previous developer created a year ago to do the exact same change last year!

So based on the above, I'm pretty sure that this is a pretty simple modification. If I could just get this app up and running locally, I'm pretty confident I can make the changes. Any advice on how to get up and running locally would be greatly appreciated.

Re: Config Production Rails App to Run Locally for Development

You probably downloaded the latest rails 3.2.  You'd have to download 2.3.2 on your development box.  In 2.3.2 you start the server like:

rails script/server

Try

gem install rails -v 2.3.2

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Config Production Rails App to Run Locally for Development

Okay, Brad, thanks. That makes sense. I will try your suggestion tonight and see what happens.

Do I need to run "gem install rails -v 2.3.2" from the root of the site or from the app sub-directory or does it matter?

What about the database itself? Do I need to change a connection string or will that automatically be mounted by SQLite?

Re: Config Production Rails App to Run Locally for Development

you don't need to be in the root of the app, gems are installed elsewhere.

You shouldn't have to touch the app/config/database.yml.

But you'd want to look at it to see which database the system uses. 

SQLite is the default,  but typically mysql is used,  the database.yml will show you which database is used.  You'd need to install the mysql database adapter gem,  BUT because your system is somewhat old,  be sure to read up on the mysql gem and download the version that is recommended for 2.3.2.  ALSO,  if it is mysql,  you'll need to download and install mysql itself,  I think that the safest version of mysql for rails 2.3.2 and the mysql adapter gem required is version 5.0.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Config Production Rails App to Run Locally for Development

Okay, made some progress. It turns out I did have Rails 2.3.2 installed, but apparently there is some sort of conflict between 2.3.x and RubyGems 1.8.15. That is what was generating the error I described in my original post.

So I downgraded to RubyGems 1.5.3 and now I don't get the error, but the server still wont start. See below for output:

c:\Sites\HSR>rails script/server
      exists
      create  app/controllers
File exists - script/server

I have create a new Rails app in a fresh directory and try to start the server, I get the same behavior.

Ideas?

Re: Config Production Rails App to Run Locally for Development

first, type

rails -v

it looks like you are still running 3.X.

You want rails -v to return 2.3.2

if it returns 3.X,  delete rails 3.X. i.e.

gem uninstall rails -v 3.X  (3.X is actually the real version return by rails -v, i.e 3.1.3, 3.2, whatever)

then type rails -v again and make sure it says

2.3.2

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Config Production Rails App to Run Locally for Development

Still struggling here, but I have finally got WebBrick at least trying to launch the app.

After several hours of trying to troubleshoot why "rails script/server" failed to launch the app, I discovered that I should have been using "ruby script/server". Arrrgh!

Anyway, when I ran that, Web brick tries to start and then I get:
C:\Sites\HSR>ruby script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
C:/Ruby187/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 25, col 0: `
test:' (ArgumentError)
        from C:/Ruby187/lib/ruby/1.8/yaml.rb:133:in `load'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:880:
in `database_configuration'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:416:
in `initialize_database'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:141:
in `process'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:
in `send'
        from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:
in `run'
        from C:/Sites/HSR/config/environment.rb:20
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
`require'
        from C:/Sites/HSR/vendor/rails/activesupport/lib/active_support/dependen
cies.rb:156:in `require'
        from C:/Sites/HSR/vendor/rails/activesupport/lib/active_support/dependen
cies.rb:521:in `new_constants_in'
        from C:/Sites/HSR/vendor/rails/activesupport/lib/active_support/dependen
cies.rb:156:in `require'
        from C:/Sites/HSR/vendor/rails/railties/lib/commands/server.rb:84
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
`require'
        from script/server:4

I have tried this on two different machines and both machines give the same error.

"rails -v" reports 2.3.2 on both as well.

Re: Config Production Rails App to Run Locally for Development

tqheel wrote:

Still struggling here, but I have finally got WebBrick at least trying to launch the app.

After several hours of trying to troubleshoot why "rails script/server" failed to launch the app, I discovered that I should have been using "ruby script/server". Arrrgh!

Anyway, when I ran that, Web brick tries to start and then I get:
C:\Sites\HSR>ruby script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
...
     
        from C:/Sites/HSR/config/environment.rb:20
...

It looks like you have something funny on line 20 of your config/environment.rb.  Hard to tell what but common problems are things like non-closed quotes or unmatched parens etc.  The problem may be earlier in the file but this problem should be in that file.