This README would normally document whatever steps are necessary to get the application up and running.
Things you may want to cover:
-
Ruby version
-
System dependencies
-
Configuration
-
Database creation
-
Database initialization
-
How to run the test suite
-
Services (job queues, cache servers, search engines, etc.)
-
Deployment instructions
-
…
Please feel free to use a different markup language if you do not plan to run rake doc:app
. [FIXED]ポエムは作成されるが、ポエムのタイトルが保存されていない –> Strong_paramsに:titleがないポエムを更新しようとするとエラーが発生する –> poems_controllerのbefore_actionに:updateがなかった[FIXED]詳細画面を開こうとすると、エラーが発生する[FIXED]詳細画面/編集画面から一覧画面にbackボタンでアクセスできない一覧画面にアクセスできない(get /poems にアクセスするとエラーが発生する)アプリをHerokuに公開して、URLを提出すること
- TODO
-
gem install bundler
- ERROR
-
The PGconn, PGresult, and PGError constants are deprecated, and will be removed as of version 1.0.
You should use PG::Connection, PG::Result, and PG::Error instead, respectively. [TODO]gem ‘pg’, ‘~> 0.20.0’
[ERROR]PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) [TODO]c9 open config/database.yml
psql
- ERROR
-
psql: could not connect to server: Connection refused
Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
- TODO
-
sudo service postgresql start
- ERROR
-
ActiveRecord::NoDatabaseError FATAL: database “day13_development” does not exist
- TODO
-
rake db:create rake db:migrate
rails s -b $IP -p $PORT
- ADD
-
c9 open .rubocop.yml
Rails:
Enabled: true
# “Missing top-level class documentation comment.”を無効Style/Documentation:
Enabled: false
# “Line is too long”を無効Metrics/LineLength:
Enabled: false
yuji911227:~/workspace (master) $ git init yuji911227:~/workspace (master) $ git remote -v yuji911227:~/workspace (master) $ git remote add origin github.com/yuji91/day13-exam.git
#CloneしたRemote Repositoryから、Commit先のRepositoryに切り替えるyuji911227:~/workspace (master) $ git remote -v origin github.com/DiveintoCode-corp/day13 (fetch) origin github.com/DiveintoCode-corp/day13 (push)
git remote rm origin git remote add origin github.com/yuji91/day13-exam.git
#Deploy to Heroku -Setup heroku login heroku create
-Asset PreCompile c9 open config/environments/production.rb
config.assets.compile = false –> config.assets.compile = true
rake assets:precompile RAILS_ENV=production
c9 open Gemfile gem ‘rails_12factor’, group: :production
bundle install
git push heroku master
heroku run rake db:migrate RAILS_ENV=production heroku config:add SECRET_TOKEN=“$(bundle exec rake secret)”
c9 open db/seeds.rb
# coding: utf-8 Blog.create(:title => 'title_01', :content => 'content_01') Poem.create(:title => 'title_01', :content => 'content_01', :author => 'author_01')
heroku run rake db:seed
- if use ActiveResource::Base
-
class Poem < ActiveResource::Base
self.site = "基礎編1で公開したアプリのHerokuのURL"
end
c9 open config/application.rb
require File.expand_path(‘../boot’, __FILE__)
require ‘rails/all’ [add]require ‘rubygems’ [add]require ‘active_resource’
上記2つのrequireをapplication.rbに記載しないと、rails sしたときに下記エラーが発生するuninitialized constant ::ActiveResource
- Fix
-
add poems_path to routes.rb
- Fix
-
add set_poem to update_action
before_action :set_poem, only: [:show, :edit, :destroy] before_action :set_poem, only: [:show, :edit, :destroy, :update]
[Fix]Strong_params # Never trust parameters from the scary internet, only allow the white list through. def poem_params
params.require(:poem).permit(:content, :auther)
end
–> params.require(:poem).permit(:title, :content, :auther)
[Fix]routes.rb Rails.application.routes.draw do
resources :poems ,only: [:show, :update, :destroy, :edit, :new, :create] root 'poems#index'
end
–> resources :poems ,only: [:index, :show, :update, :destroy, :edit, :new, :create]
- SEE ALSO
-
Rails Better Errorsでデバックする (Ajaxでのエラーも) qiita.com/shizuma/items/922eea72165c67a4a6e8
今更聞けないpryの使い方と便利プラグイン集qiita.com/k0kubun/items/b118e9ccaef8707c4d9f
byebugでRubyスクリプトをコマンドラインデバッグするqiita.com/aosho235/items/6f988a0b5262b95ca460
CentOSでPostgresの環境でRailsアプリを動かす時に出会ったエラーqiita.com/ms2sato/items/ef4bf05065cc3eed885e
railsのapp作成でmysqlを使用する時の導入とハマるところrake db:createができるまでの流れqiita.com/Kaisyou/items/17142ff2d080d565fedc
rails s -p $PORT -b $IPするとPG::ConnectionBadが出たときqiita.com/Yukiya025/items/1efd9e200ea476dc466e
Rails でリンクパスを生成する方法色々・・とRails console で 生成される path を確認したい時qiita.com/mm36/items/f266977e12df9d1dc54
Rubocopについてqiita.com/t-vinn/items/fe57b5d6440712016742 rochefort.hatenablog.com/entry/2014/08/14/073000 wonderwall.hatenablog.com/entry/2015/08/17/213718 qiita.com/necojackarc/items/8bc16092bbc69f17a16d codeiq.jp/magazine/2014/06/11433/
ApplicationRecordについてtechracho.bpsinc.jp/hachi8833/2017_04_27/36050