I am new to Ruby on rails. Recently I am working on a project done halfway by another programmer. What I did was I cloned his repository and installed all the required bundles and gems etc so that I can run development locally. It used to work all the time when I run rails server and visit localhost:3000
However, today I set up a dual boot Ubuntu alongside windows 8.1. Then, I followed the exact same process as before to install required gems and set up the environment.
However, this time, when I run rails server and visit localhost:3000
I run into the following problem:
could not connect to server: Connection timed out Is the server running on host "xx.xx.xx.xxx" and accepting TCP/IP connections on port 6543?
This is weird, because it used to work without me configuring anything on the database.yml.
If I start a new rails project and do
rails new projectName -d postgresql
it works fine after I edited the database.yml file to the correct credential.
So my question is, if I cloned a repository and started to collaborate with another programmer on the project, how should I set up the postgresql database for me?
Thank you very much.
If you want to make possible for everyone to have their own local database configuration, consider to create database.yml.example file. Some people think that it's a bad practice, from my experience, it's very handy.
How to make it:
Rename database.yml to database.yml.example.
Commit it
Add database.yml to .gitignore and commit this change.
Make a copy of database.yml.example and rename it back into database.yml.
Now when someone will clone your repo, she will have to create her own database.yml file from .example. So everyone will have his own database configuration.
Ok, I found the problem. It is the host address, I was using the wrong host address because my co-programmer changed the address. So, ya, if the host is correct in the database, then you should be able to see the page
Related
After developing in Rails on a virtual Linux machine, I just recently installed Windows Subsystem for Linux. Before the Christmas weekend, it was working just fine, but as of this morning, when I try and start up my rails server, it gives me the following complaint:
Could not load database configuration. No such file - ["config/database.yml"]
Of course, when I go into my config folder, database.yml is there - just like it was last week. So I'm confused why it can't find the file now when it absolutely could find it before. Is this some sort of WSL quirk that makes the file hard to find for some reason?
This is most likely guesswork, but I assume that there is a permission issue. If config/database.yml has insufficient ownership or read-levels, it may not be found by your Rails application.
For further diagnose, I recommend posting the output of:
# Get permission details for your config
ls -laZ config/database.yml
And maybe some details of which user is starting the Rails application (effectively which user owns the Ruby process).
I ssh copied a rails app from a staging server because the development repository has been lost. My goal is to create a new development code base using the deployed code as a source. So far I have removed a hidden .bundle folder and replaces several aliases with folders and files. I then ran bundle install. For the database I did a sql dump from staging and used it to build a development database. I think I'm ready to run rails server. But when I try to run rails server in the base directory. It gives me the rails command line help as if I was running rails s in a directory with no app.
I'm not even sure if it is possible to reverse a deploy this way. I've looked at the rails guide on the app initialization process and all the files seem to be in place.
Remember that for Rails to start up, you need bin/rails, bin/bundle, config/boot, etc.
If you restore those files, it should work again.
I'm running the rails-composer script with
rails new myproject -m https://raw.github.com/RailsApps/rails-composer/master/compser.rb
And everything goes along smoothly until it asks me if I want to go ahead and drop the db in. I say yes. All drops fail, and all creations fail.
Everything else finished fine. And testing the site brings up a beautiful error site with lots of details on how the database password wasn't accepted. But of course it was never created...
How do I give the script permission to create the database without a password? I've tried preempting creating the username as the app name in postgres. I tried building the Rails project as the postgres user.
It should be a simple and straightforward solution since the rest is automated.
Did you specify something other than SQLite for the database?
From the README:
Choose “SQLite” for the easiest setup. If you choose PostgreSQL or
MySQL, the databases must be installed and running before you run
Rails Composer.
Rails composer does not install and setup your database server for you. It assumes there's a properly named database already present before you run this if you're using PostgreSQL or MySQL.
I have started developing a new Rails app on my server using RVM, Rails 3, & Ruby v1.9.2. I am using Git as my code repository. It's a simple app and I don't want to use an extra server. I just want to deploy my app directly from the same server I am developing on.
I've installed Phusion Passenger w/ Apache to serve my app, but have realized that I can't do that pointing to my development directory as my RAILS_ENV is set to "development". (I found I got file permission errors on the asset pipeline and other issues when I attempted to set RAILS_ENV to "production" and serve the app)
What's the simplest/easiest way to deploy the app? Can I simply:
1) Create a separate user to run rails production (Rails in dev currently runs as me on my Ubuntu server)
2) Clone my repo into a separate dir and configure Apache accordingly
3) Seed my database with the data needed for production (not much data needed here)
4) What else?
I've looked briefly at Capistrano, but it seems like overkill for this simple app. I only need to be able to provide a simple web interface for some data entry. Seems like git push should be sufficient, but I haven't done this before so maybe I'm wrong? Also, if I git push how do I ensure file permissions in the "production" directories are all set properly, particularly for any new files that get created in the originating app directory structure?
Thanks for any ideas.
No- you do not need Capistrano for the above; at this stage I feel it will only serve to confuse you further.
I'd suggest you first save your repo to a private Github or free BitBucket account. What you should do is keep one folder for 'development'.
Remember that Passenger is 'just' a module working with Apache. So what you need to do is setup a virtual host under apache and direct that to another folder on your system. For this example, consider:
~/rails/myapp_development/ and ~/rails/myapp_production/
Passenger always runs the app in production, so that should not be an issue. You can do bundle --without=production in your development setup to ignore any gems listed in the Gemfile under the production namespace, i.e. say you've got the mysql adaptor specified, you can ignore this and have Rails only rely on the SQlite gem.
You can now simply develop in the development folder, commit, push to BitBucket. Deploying will be as simply going into the production folder and doing a git pull and touch tmp/restart.txt.
Especially when considering a fresh Rails project, what does your version control and deployment workflow look like? What tools do you use?
I'm interested in answers for Mac, *nix and Windows work machines. Assume a *nix server.
I'll edit for clarity if need be.
Create a copy of my personal Rails 2.1.1 template with preinstalled plugins and frozen gems.
Change DB passwords, session secret/name and deploy.rb.
Create a private or public repository on GitHub as needed.
Push the empty rails project to GitHub.
SSH to Server and configure apache (copy Virtual Host file and mongrel config files from old project)
Create empty database on MySQL server
cap deploy:setup && cap deploy:cold
If everything works so far: Start developing and committing to GitHub. cap deploy as needed.
Update: Don't forget to write tests for everything you do!
Using Windows Vista and a fresh Ubuntu install at Slicehost.
Create a new empty project in
NetBeans.
Fire deprec (http://www.deprec.org) to install
the Rails stack, including version
control, on the target slice.
Commit the empty project to Subversion.
Using Capistrano, test deploy.
Begin actual development after I've verified that I can access the
Rails start page and, possibly,
scaffolding. (This is really not
necessary because I've done this several times and the software works like it says it does.)
Deprec is seriously magic -- it takes the time it takes to clean-start a Rails project (including server configuration and all that jazz) from about a working day down to about an hour -- and that is an hour where you can be doing coding while everything installs.
this guy documents every workflow he's ever experienced
http://subtlegradient.com/articles/2007/03/30/web-development-environment-and-workflow