Ich habe gerade eine neue Rails 5.0.0 App gemacht. Alles hat gearbeitet, bis ich beste Ordnung entschieden Vermögen für Heroku vorzuzukompilieren:Rake-Fehler bestehen auf eine Benutzerrolle, die meinen App-Namen ist?
RAILS_ENV=production bundle exec rake assets:precompile
ich dann diesen Fehler sehen. Ich weiß nicht, warum die Rolle der Name meiner App sein soll. Ich habe mich bis zu diesem Zeitpunkt vorkompiliert. Nur zwei Migrationsdateien hinzugefügt (unten aufgeführt).
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "MYAPPNAME" does not exist
/Users/james/MyApps/MYAPPNAME/app/models/model.rb:6:in `get_percent_change'
/Users/james/MyApps/MYAPPNAME/lib/tasks/trade_wave_tasks.rake:3:in `block in <top (required)>'
/Users/james/MyApps/MYAPPNAME/config/application.rb:12:in `<class:Application>'
/Users/james/MyApps/MYAPPNAME/config/application.rb:10:in `<module:MYAPPNAME>'
/Users/james/MyApps/MYAPPNAME/config/application.rb:9:in `<top (required)>'
/Users/james/MyApps/MYAPPNAME/Rakefile:4:in `require_relative'
/Users/james/MyApps/MYAPPNAME/Rakefile:4:in `<top (required)>'
/Users/james/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
/Users/james/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
PG::ConnectionBad: FATAL: role "MYAPPNAME" does not exist
/Users/james/MyApps/MYAPPNAME/app/models/model.rb:6:in `get_percent_change'
/Users/james/MyApps/MYAPPNAME/lib/tasks/trade_wave_tasks.rake:3:in `block in <top (required)>'
/Users/james/MyApps/MYAPPNAME/config/application.rb:12:in `<class:Application>'
/Users/james/MyApps/MYAPPNAME/config/application.rb:10:in `<module:MYAPPNAME>'
/Users/james/MyApps/MYAPPNAME/config/application.rb:9:in `<top (required)>'
/Users/james/MyApps/MYAPPNAME/Rakefile:4:in `require_relative'
/Users/james/MyApps/MYAPPNAME/Rakefile:4:in `<top (required)>'
/Users/james/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
/Users/james/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
Tasks: TOP => get_percent_change
(See full trace by running task with --trace)
Anfangs gab mir irgendein Rake Befehl ein Problem. Ich habe diese Probleme behoben und alle Rake-Befehle funktionieren - außer diesem! (dh Rake db: reset) Ich habe auch die postgresql USER und ROLE erstellt, aber es wird immer noch der gleiche Fehler angezeigt. Ich starte psql neu und rake db: reset.
Hier sind die Migrationsdateien:
das Modell Erstellt:
class CreateMyModel < ActiveRecord::Migration[5.0]
def change
create_my_model :models do |t|
t.timestamps
end
end
end
Added eine Säule:
class AddPercentChangeToMyModelTable < ActiveRecord::Migration[5.0]
def change
remove_column :my_models, :percent_change, :string
add_column :my_models, :percent_change, :string
end
end
mit einem Schwimmer Changed es:
class ChangePercentChangeToFloatOnMyModelTable < ActiveRecord::Migration[5.0]
def change
add_column :my_models, :percent_change, :float, precision: 8
end
end
I verwende ich auch immer wenn g em so dass ich einen Rake Job haben (die sich in Aufgaben/my_rake_job.rake)
desc 'get latest percent change'
task get_percent_change: :environment do
MyModel.get_percent_change
end
Und hier ist mein Schema:
create_table "bots", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "mymodels", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.float "percent_change"
end
create_table "tweets", force: :cascade do |t|
t.string "message"
t.string "string"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Config/Datenbank
# PostgreSQL. Versions 9.1 and up are supported.
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: MYAPP_development
test:
<<: *default
database: MYAPP_test
production:
<<: *default
database: MYAPP_production
username: MYAPP
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
Und mein Juwel Datei :
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'twitter'
gem 'figaro'
gem 'randumb'
gem 'whenever', :require => false
gem "stock_quote"
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Nach dem Ablegen der Rolle und re macht es meine psql \ du tabelle sieht so aus:
ccap | Superuser, Create DB | {}
Bitte lassen Sie mich wissen, welche anderen Dateien zum debuggen notwendig sind.
Was Sie in der 'config/database.yml' Datei haben? –
Ich habe es nur zur Frage hinzugefügt – user3390658