0

I am trying to deploy my first rails application on digital ocean in Ubuntu, I am unsure if I am doing this right. I initially had my production database in postgres and test and production in sqllite. In frustration, I changed all my databases to postgres my changing the database.yml. I am unsure if I did that correctly But I had this error: ActiveRecord::StatementInvalid (SQLite3::ReadOnlyException: . When I was in sqllite. I was not sure if I had to tell the server to switch to production mode or if it was configured to use sqllite.

What I want to do is use postgres instead of sqllite. I am using nginx and Unicorn. MY database is blank so I dont need to transfer anything. I have made the postgres database within postgres, I just need to point my app to that database. (I am unaware if I need to do something else

I have used this database.yml

development:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: blog_development
  pool: 5
  username: bob
  password: password

test:
  adapter: postgresql
  encoding: unicode
  database: blog_test
  host: localhost
  pool: 5
  username: bob
  password: password

production:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: blog_production
  pool: 5
  username: bob
  password: password

Gem file:

source 'https://rubygems.org'
ruby '2.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'jquery-ui-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'bootstrap-sass' # for using bootstrap-rails"

gem 'faker'

gem 'will_paginate'

gem 'annotate', '~> 2.6.5'

gem 'font-awesome-rails' # for using font-awesome icons

gem 'redcarpet', '~> 2.1.1'
gem 'coderay', '~> 1.1.0' # For nice code snippets


gem 'devise'

gem 'sidekiq'

gem 'haml-rails'

group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'meta_request'
  gem 'guard-rspec'
end

group :test do
  gem 'capybara'
  gem 'factory_girl_rails', '4.2.0'
end

gem 'pg', '0.15.1'

group :development, :test do
  gem 'rspec-rails'
  # Use sqlite3 as the database for Active Record in testing
end

group :production do

  gem 'rails_12factor', '0.0.2'
end

I have the rest of the code on my github: https://github.com/RubyQuarry/Bootstrap_blog

6
  • Under what circumstances are you getting that error? When you try to start the console? Run the server? Commented Nov 16, 2014 at 21:47
  • This is happening when I try to write to the application (make a comment) at: 104.236.51.180/blogs/10 Commented Nov 16, 2014 at 21:54
  • Can you run rake db:drop db:create db:migrate? Can you log into the Rails console and create a Comment object through that interface? If not, what is the error? Commented Nov 16, 2014 at 22:04
  • Did you restart everything after changing databases? Sounds like your application still thinks it is talking to SQLite. Commented Nov 16, 2014 at 22:11
  • I got it working through running, rake db:drop db:create db:migrate thank you @Bryce Commented Nov 16, 2014 at 22:30

1 Answer 1

3

Run rake db:drop db:create db:drop to drop your old database(s) and recreate the new ones in Postgres.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.