What's the fastest Ruby on Rails setup for Windows 7? - ruby-on-rails

I have InstantRails installed along with WeBrick and sqlite3.
What exactly do I type in the Windows cmd console to setup a db called 'development' and to get the entire things running?
This is my #&%^# 4th day of installation. I can get everything running on my localhost EXCEPT setup my db. I'm not a programmer so if you have a good url for beginner tutorials that would be great.
Please tell me exactly what I need to type in the cmd console (or what console I need) to make my db hold the information.
I was typing $ sqlite3 db/development.sqlite3 to (boot up?) the db.
Then I typed: CREATE TABLES (code)
Note - I already tried rake db:migrate

Try rake db:migrate (assumimg you have at least 1 migration created ) . The db should be created automatically.

Related

warning: circular argument reference - now rake aborted! on rake db:migrate

On rake db:migrate, I am getting following error.
ruby-2.2.1/gems/activesupport-4.0.2/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
My rails gem gem 'rails', '4.0.2'
What's the solution for this?
From your error, it sounds like you are trying to use a Postgres database with your rails project. Basically, postgres runs separately from your rails project. You need to make sure you have:
a) installed postgres using something like homebrew
b) found a convenient way to start your postgres server when you need to (I recommend the one on postgresapp.com)
c) actually started the server before running the command that's producing this error (e.g., through opening the postgresapp or in a separate terminal window)
Conceptually, think of it this way: you can't migrate (e.g. 'change') a database that's inaccessible because the postgres server is down. That's what the error means.
As an alternative, you can use SQLite instead of Postgres. SQLite does NOT run as a separate process (https://www.sqlite.org/serverless.html), so you will run into these problems less. However, in your ruby code, you will need to pay attention to exactly how to configure your app for a postgres database or a sqlite database, whichever you choose. Here is a great SQLite tutorial for initial set-up:
http://www.integralist.co.uk/posts/active-record.html

Error when creating database record on rails console

I'm trying to create a new record through the rails console but I'm getting the following error:
PG::ConnectionBad: FATAL: database "my_database_development" does not exist
I've recently changed from Sqlite3 to PG to be able to deploy to Heroku. Is this what is giving the error?
Thanks a lot!
It looks like you have not yet run
rake db:create
This will "create" the databases on your PostgreSQL server. A step that you didn't have to do with SQLite, but Postgres requires it. As TK-421 said, make sure that your database.yml is configured for your OS and Postgres, not SQLite.
Here is a (possibly outdated) Railscast on the topic.
http://railscasts.com/episodes/342-migrating-to-postgresql
Is this running locally, or on Heroku? In config/database.yml, the local user you specify will need to have CREATEDB privileges (as a superuser, for example).
There's a little more configuration required in this case than for SQLite. Google will show you a bunch of tutorials specific to your OS.
If you see this problem in production on heroku, start the console like this:
rails console production
If you have that problem in development on your machine, check your config/database.yml. It is points to a local development database that does not exist.

How to switch my Rails app to postgresql from Sqlite3?

So I started working on a Rails app recently and we decided (well not me, the person working on it with me) that we should switch from Sqlite3 to Postgresql. I've installed Postgresql on our server properly, created the databases for dev, prod, and test, and updated my Gemfile and database.yml files with the code for Postgres. The thing I'm unsure of now, is how to switch out all the files in the db directory with the Postgres databases. Do I just delete the contents of the db directory in my app and run rake db:create?
You'll want to edit config/database.yml to use postgresql instead of sqlite.
The migrations in db/migrate/*.rb are hopefully cross-database compatible, and wont need to be changed.
Running rake db:create db:migrate with the new database.yml should create the PostgreSQL database and you'll be up and running.
In reality, you'll probably run into various problems, but this will be a starting point.

Delayed_job claims database doesn't exist

I've set up delayed_job and it works fine under development.
However, whenever I attempt to run the script under production and run
RAILS_ENV=production script/delayed_job start
I get this:
/Users/simon/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `initialize': FATAL: database "myapp_production" does not exist (PG::Error)
It feels like I'm missing something really basic here (from what I gather it's looking for the production database on my local machine?), but I'm a bit stuck as to where to look and what might cause this problem.
Any pointers would be greatly appreciated.
Well this is pretty much obvious - you are starting your dj in production env, so it tries to connect to the db that is described in the "production" section of config/database.yml. It seems that you haven't created this db yet.
To create this DB run in terminal
RAILS_ENV=production bundle exec rake db:create

Welcome aboard ActiveRecord::ConnectionNotEstablished

I'm using Ubuntu, with Rails 3.0.1 with mysql2 socket.
When i do runing install, rake db:create and after rails server, my Welcome aboard, shows ActiveRecord::ConnectionNotEstablished in About your application’s environment
What i do?
Had the same problem on rails 3.1.1:
rake db:create - ok
rails console and some DMLs - ok
but accessing info from the web-page resulted in ActiveRecord::ConnectionNotEstablished.
A rails server restart helped.
It sounds like your MySQL server isn't running. You'll need to install MySQL if you haven't already (apt-get install mysql-server should do it). Once it's running, you'll need to set up a user and database for your app, and note the username and password so that you can put that information in config/database.yml within your app.
This link will be useful if you need any help with those steps.
You'll need to do some more debugging to work it out.
How are you running your server?
Make yourself a model.
rails generate model Something name:string
Then try running rake db:migrate
Does this work?
If it does, then you must be running your server in a different way (maybe you're running it in production mode?)
Try rails console and try to do Something.count
If all of those work
then I'd suggest you try restarting your server.
rails server

Resources