gpt4 book ai didi

ruby-on-rails - ActiveRecord::StatementInvalid (SQLite3::ReadOnlyException: 当使用 postgres

转载 作者:行者123 更新时间:2023-11-29 14:20:59 25 4
gpt4 key购买 nike

我正在尝试在 Ubuntu 中的 digital ocean 上部署我的第一个 Rails 应用程序,我不确定我这样做是否正确。我最初在 postgres 中有我的生产数据库,在 sqllite 中有测试和生产。令人沮丧的是,我将所有数据库更改为 postgres 我更改了 database.yml。我不确定我这样做是否正确但是我有这个错误:ActiveRecord::StatementInvalid (SQLite3::ReadOnlyException: 。当我在 sqllite 中时。我不确定我是否必须告诉服务器切换到生产模式或者它是否被配置为使用 sqllite。

我想做的是使用 postgres 而不是 sqllite。我正在使用 nginx 和 unicorn 。我的数据库是空白的,所以我不需要传输任何东西。我已经在 postgres 中创建了 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

gem 文件:

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

最佳答案

运行 rake db:drop db:create db:drop 以删除旧数据库并在 Postgres 中重新创建新数据库。

关于ruby-on-rails - ActiveRecord::StatementInvalid (SQLite3::ReadOnlyException: 当使用 postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26962010/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com