0

我想在Ubuntu的数字海洋部署我的第一个rails应用程序,我不确定我是否做这个权利。测试和生产sqllite。在挫折中,我改变了所有我的数据库postgres我更改database.yml。我不确定如果我做到了这一点正确但我有这个错误:ActiveRecord :: StatementInvalid(SQLite3 :: ReadOnlyException:是sqllite。我不知道是否必须告诉服务器切换到生产模式,或者如果它被配置为使用sqllite。ActiveRecord :: StatementInvalid(SQLite3 :: ReadOnlyException:当使用postgres

我想要做的是使用postgres而不是sqllite。我使用nginx和我的数据库是空白的,所以我不需要传输任何东西。我做了postgres da在postgres中,我只需要将我的应用程序指向该数据库即可。 (我不知道如果我需要做些别的事情

我已经使用这个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 

宝石文件:

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 

我有我的GitHub上的代码的其余部分: https://github.com/RubyQuarry/Bootstrap_blog

+0

在什么情况下你会得到那个错误?当你尝试启动控制台?运行服务器? – Bryce

+0

当我尝试写入应用程序(发表评论)时发生这种情况:http://104.236.51.180/blogs/10 – applejuiceteaching

+0

您可以运行'rake db:drop db:create db:migrate'吗?你能登录到Rails控制台并通过该接口创建一个Comment对象吗?如果不是,那么错误是什么? – Bryce

回答

3

运行rake db:drop db:create db:drop放弃旧数据库(一个或多个),然后重新创建新的Postgres里。

相关问题