Error in Ruby while installing spree - ruby-on-rails

Hello friends I am newbie in Rails.I installed rails in my ubuntu 10.10. As per my project requirement I installed
spree.Then I made application using command
rails new mystore
then I created the store application, switched to its folder to continue work directly in that application with command
$ cd mystore
then I made install spree_sample by the command
rake spree_sample:install
After that I made populating my database with this command then it showed error like this
rake aborted!
syntax error on line 20, col -1: `test:
adapter: mysql2
encoding: utf8
reconnect: false
database: mystore_test
pool: 5
username: root
password:root
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: mystore_production
pool: 5
username: root
password:root
I was using this site for reference.Just have a look on it.I want to make spree commerce in ruby on rails.So please help me.I am newbie to rails.

You have syntax error in your database.yml config file. That's not related to Spree or to Ruby.
Should be "password: root" instead of "password:root"

Related

Moving from Sqlite3 to PostgreSQL Rails

I'm trying to move my database to a PostgreSQL because I'm putting it up on Heroku.
Followed Railscast #342. Installed PostgreSLQ with its dependencies on my Ubuntu machine. When I installed it I think a user was created. I used this user in my database.yml. It looks like this:
production:
adapter: postgresql
encoding: unicode
database: dlrvbtApp1_production
pool: 5
username: jdartland
password:
development:
adapter: postgresql
encoding: unicode
database: dlrvbtApp1_development
pool: 5
username: jdartland
password:
test:
adapter: postgresql
encoding: unicode
database: dlrvbtApp1_test
pool: 5
username: jdartland
password:
Installed pg gem and the taps gem.
Ran a Bundle install, created the databases with rake db:create:all
Started the taps senatra server with taps server sqlite://db/development.sqlite3 jdartland secure
The server started. And tried to pull the SQL to my new development db through this command.
taps pull postgres://jdartland#localhost/dlrvbtApp1_development http://jdartland:secret#localhost:5000
I then get this error:
Failed to connect to database:
Sequel::DatabaseConnectionError -> PG::ConnectionBad: fe_sendauth: no password supplied
I have tried and tried, created new databases, canhing the .yml, pg_config and so on but I can't get it to work.
This is my first time working with PostgreSQL and Heroku, please give me a hand! :)
Change the user on production to localhost and leave the password blank.
production:
adapter: postgresql
encoding: unicode
database: dlrvbtApp1_production
pool: 5
username: localhost
password:
If you're moving your database to Heroku, the whole thing is just a case of connecting your DB to Heroku's PG one, and migrating the data.
Did you receive database details from Heroku?
They basically use Amazon to serve their DB's, and you'll get some credentials to put into your yml file for it. Here is an example of one of our live Heroku apps:
production:
adapter: postgresql
database: ********
pool: 5
username: ****************
password: ****************
port: 5432
host: ec2-54-228-234-250.eu-west-1.compute.amazonaws.com
Ways To Migrate To PostgreSQL (Heroku)
If you're looking to migrate your data from SQLite3 to PostgreSQL, I found a really good tutorial on how to do this here. Only problem is that it's not for SQLite lol
If you're trying to pull down your database from Heroku into a local postgres database, use pg:pull or pgbackups:
https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull
https://devcenter.heroku.com/articles/heroku-postgres-import-export
You should also look into using foreman and a .env file to setup your DATABASE_URL similar to how it's ran on Heroku, for dev/prod parity:
https://devcenter.heroku.com/articles/procfile#developing-locally-with-foreman
Got It working by following another post here on stack. Simply went up one directory, installed taps Gem install Taps. Uninstalled Rack gem gem uninstall rack 4 then Reinstalled it gem install rack --version 1.0.1. Did not do this in my progect directory, just simply in RVM. Then Pulled the database from the same directory. (not from my project directory).
Here is the Whole tread: taps migration failing from sqlite to postgres rails4, ruby 1.9.3
Hope it helps someone with the same problem.
Now just one thing left, Push it to heroku..... We'll see how that goes...hehe
Thanks for all help!

Ruby On rails spree commerce installation

Hi friends am trying to bring spree commerce but i got error while am trying this command on windows 7 spree install
I got an error like this please help me ..
C:/Ruby193/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): could not find
expected ':' while scanning a simple key at line 17 column 3 (Psych::SyntaxError)
should have single space after : in database.yml, for each line example
development:
adapter: mysql
encoding: utf8
reconnect: false
database: form_dev
pool: 5
username: user
password: password
host: localhost

Creating Rails 3.1 app with Postgresql database (OSX Lion)

I cant seem to find an up-to-date guide to creating a new Rails 3.1 app with a Postgresql database. I would greatly appreciate a guide through that process.
Since Rails 3, the framework is completely database-agnostic.
What that means is, all you have to do is 2 things:
Include the pg gem in your Gemfile: gem 'pg'
Make sure your database.yml file is using postgresql as the adapter.
You can accomplish this automatically when you create a new app by appending the --database=postgresql flag:
rails new myapp --database=postgresql
But if you've already created the app, then just comment out gem 'sqlite3' in your Gemfile, add in gem 'pg', run bundle, and then change your database.yml file to use the correct adapter.
Of course, it goes without saying that you will also need to install PostgreSQL itself, but that is something you can easily find on google.
To elaborate on bricker's answer... After running:
$ rails new myapp --database=postgresql
Here is what your database.yml will look like:
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password:
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp
password:
production:
adapter: postgresql
encoding: unicode
database: myapp_production
pool: 5
username: myapp
password:
Running:
$ bundle exec rake db:create:all
will create the databases for you if you have PostgreSQL installed. The easiest way to install PostgreSQL is http://postgresapp.com/
I found you have to either add the username, in the example above - myapp, to the PostgreSQL database or change the username to an existing user.
As of Rails 4, bricker's answer does not work, at least not for me.
This command does the trick instead:
rails new new_app --d = postgres

Ruby on Rails project setup

I am trying to set up a Ruby on Rails project by following the instructions on their website. I am using MySQL database. When I try to create a project using the rails -d mysql demo command. I just get the default usage: instructions. Something like below...
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
I am not sure what is the correct syntax based on --database?
I am using the instructions on this site, is it something related to version? I am using Rails 3.0.3
I suggest doing the following.
$ sudo gem install rails mysql
$ rails demo
$ cd demo
$ edit database.yml
# change database type from sqlite3 to mysql
$ rails server -p 4000
# open a web browser to localhost:4000 and see if you see some, else look at the error log in the terminal
Edit
For a detailed tutorial I suggest This Tutorial from railstutorial.org
This is giving some problems. The database.yml looks like this:
development:
adapter: mysql
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: mysql
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: mysql
database: db/production.sqlite3
pool: 5
timeout: 5000
When I changed 'adapter' to mysql, and then try to start server, it still says sqlite.dll not found. I guess this is because the project was set up for sqlite3, so just changing the databse.yml is not enough.
For learning purposes, it is ok for me to use sqlite db(mysql is not mandatory), but where do I put the dll file?
P.S.- This is too long for a 'comment', so please bear with me for posting it under Answer.
If you want to have you project to work with PostgreSQL or sqlite, you'll need t specify it using the --database flag in the rails new command. Check out my answer here to a related issue.

Convert a Ruby on Rails app from sqlite to MySQL?

I made an app in Ruby on Rails and now I want to get it hosted. However, they require that I use MySQL and I set it up using sqLite3. Is there any way to convert it to use MySQL?
Step 0
To be safe, I recommend experimenting a bit with this technique in a virtual machine. Save yourself a bunch of heartache and build a virtual machine, check out your code, and have a safe playground that you can throw away if tragedy strikes.
Step 1
Make a backup copy of your database.yml file.
(from your application root)
cp config/database.yml config.database.yml.sqlite3
Step 2
Make a backup copy of your data
For Rails 3, install the YAML DB gem: https://github.com/ludicast/yaml_db
by running
gem install yaml_db
and then add to your Gemfile.
gem 'yaml_db'
For Rails 2.x install the YAML DB plugin:
script/plugin install git://github.com/adamwiggins/yaml_db.git
Run the dump task
rake db:dump
Step 3
Update your config/database.yml file. You will find entries like
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
timeout: 5000
Change them to
development:
adapter: mysql
encoding: utf8
reconnect: false
database: **myapp_development**
pool: 5
username: **root**
password: **supersecretpassword**
**socket: /opt/local/var/run/mysql5/mysqld.sock**
test:
adapter: mysql
encoding: utf8
reconnect: false
database: **myapp_test**
pool: 5
username: **root**
password: **supersecretpassword**
socket: **/opt/local/var/run/mysql5/mysqld.sock**
production:
adapter: mysql
encoding: utf8
reconnect: false
database: **myapp_production**
pool: 5
username: **root**
password: **supersecretpassword**
socket: **/opt/local/var/run/mysql5/mysqld.sock**
Be sure to update the values surrounded by asterix as appropriate for your platform! The socket value is only good for Mac OSX using MacPorts. Most flavors of linux do not require this value.
Step 5
If you have some errors in the following step, you might have to install the mysql or mysql2 gem:
sudo gem install mysql
or
sudo gem install mysql2
Have rake create your database
rake db:create
rake db:schema:load
Step 6
Use YamlDb to reload your data into MySql
rake db:load
As long as you have not written any SQL statements that run in sqlLite3 and not MySQL (which you won't have if all your database access is via ActiveRecord and ActiveRecord migrations) then all you need to do is change the database adapter in your database.yml config file.
Check Taps. I've successfully converted a Mysql database to Postgres with it --it should support SQLite.
Edit: Including working link from cony's comment here.
If there's no data to migrate, simply update database.yml and run 'rake db:schema:load' in the new environment. (NOT db:migrate which should only be used for incremental migrations!)
myproject user$ cd
user $ rails new myproject -d mysql
Say 'no' for all question but for Overwrite .../myproject/config/*database.yml*? (enter "h" for help) [Ynaqdh] say 'yes'.

Resources