質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1638閲覧

ブランチをmergeした際にエラーが発生、データがgitへ保存されていない?(Railsチュートリアル5章にて)

babi-0105

総合スコア10

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/01/10 10:08

#解決したい事
・正常に保存されていないことは分かったものの、ここからの修正方法が見当つきません。

⇩merge、git pushする前
イメージ説明
⇩merge,git push後
イメージ説明

#ソースコード

ec2-user:~/environment/sample_app (rails-flavored-ruby) $ git init Reinitialized existing Git repository in /home/ec2-user/environment/sample_app/.git/ $ git add -A $ git commit -m "Finish layout and routes" [rails-flavored-ruby 15cc683] Finish layout and routes 17 files changed, 217 insertions(+), 54 deletions(-) create mode 100644 app/assets/images/kitten.jpg create mode 100644 app/assets/images/rails.png create mode 100644 app/assets/stylesheets/custom.scss create mode 100644 app/views/layouts/_footer.html.erb copy app/views/layouts/{application.html.erb => _head.html.erb} (62%) create mode 100644 app/views/layouts/_header.html.erb create mode 100644 app/views/layouts/_shim.html.erb rewrite app/views/layouts/application.html.erb (85%) rewrite app/views/static_pages/home.html.erb (100%) create mode 100644 test/helpers/application_helper_test.rb create mode 100644 test/integration/site_layout_test.rb $ git checkout master Switched to branch 'master' Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) $ git merge filling-in-layout merge: filling-in-layout - not something we can merge $ rails test 0 failures, 0 errors, 0 skips $ git push Counting objects: 6, done. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 1.21 KiB | 1.21 MiB/s, done. Total 6 (delta 4), reused 0 (delta 0) To bitbucket.org:babi0105/sample_app.git 06772fa..79ce12f master -> master $ git push heroku

#起っている事
・herokuへのpushは正常にできているみたいでした。
・ただ、git addを行う前にローカルのブランチで表示できていた、ものとは異なる、以前作成したサイトが表示されました。
#考えられる原因
・余計なコマンドを打ってしまったためなのか、mergeまたgitへのpushが正常にできていない
→git initが必要無かったのかと。
#試したこと
・もう一度、もといたブランチ(filling-in-layout)へ戻り、herokuへpushしたところ結果は変わらずでした。

ec2-user:~/environment/sample_app (master) $ git checkout -b filling-in-layoutSwitched to a new branch 'filling-in-layout' ec2-user:~/environment/sample_app (filling-in-layout) $ git add -A ec2-user:~/environment/sample_app (filling-in-layout) $ git commit -m "Finish layout and routes" [filling-in-layout c19d09f] Finish layout and routes 1 file changed, 17 insertions(+) create mode 100644 test/integration/site_layout_test.rb ec2-user:~/environment/sample_app (filling-in-layout) $ git checkout master Switched to branch 'master' Your branch is up-to-date with 'origin/master'. ec2-user:~/environment/sample_app (master) $ git merge filling-in-layout Updating 79ce12f..c19d09f Fast-forward test/integration/site_layout_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/integration/site_layout_test.rb ec2-user:~/environment/sample_app (master) $ git push Counting objects: 5, done. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 648 bytes | 648.00 KiB/s, done. Total 5 (delta 2), reused 0 (delta 0) To bitbucket.org:babi0105/sample_app.git 79ce12f..c19d09f master -> master ec2-user:~/environment/sample_app (master) $ git push heroku ・ ・省略 ・ ec2-user:~/environment/sample_app (master) $ git checkout -b filling-in-layoutfatal: A branch named 'filling-in-layout' already exists. ec2-user:~/environment/sample_app (master) $ git checkout filling-in-layoutSwitched to branch 'filling-in-layout' ec2-user:~/environment/sample_app (filling-in-layout) $ git checkout master Already on 'master' Your branch is up-to-date with 'origin/master'. ec2-user:~/environment/sample_app (master) $ rails t Running via Spring preloader in process 17685 /home/ec2-user/environment/sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ec2-user/environment/sample_app/config/application.rb to limit the frameworks that will be loaded. Started with run options --seed 47000 ERROR["test_full_title_helper", ApplicationHelperTest, 0.006054255001799902] test_full_title_helper#ApplicationHelperTest (0.01s) NameError: NameError: undefined local variable or method `full_title' for #<ApplicationHelperTest:0x0000000003321a60> test/helpers/application_helper_test.rb:5:in `block in <class:ApplicationHelperTest>' FAIL["test_layout_links", SiteLayoutTest, 0.29685982999944827] test_layout_links#SiteLayoutTest (0.30s) Expected exactly 2 elements matching "a[href="/"]", found 0.. Expected: 2 Actual: 0 test/integration/site_layout_test.rb:10:in `block in <class:SiteLayoutTest>' 6/6: [=================================] 100% Time: 00:00:00, Time: 00:00:00 Finished in 0.33757s 6 tests, 9 assertions, 1 failures, 1 errors, 0 skips

#補足
情報が足りないかもしれません。
また、その際はご指摘いただきたいです。
返信お待ちしております。
よろしくお願いします.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

画像とcssが表示されていないように見えます。
画像とcss, javascript をdevelopment環境以外で
表示するにはasset precompileをする必要があります。

asset pipelineはruby以外の特に実行が必要ないファイルを
サーバに負荷の低い方法で配信するためにあります。
本番環境向けの負荷の少ない用途なので、development環境ではオフになってます。

push後に以下のコマンドでasset precompileができるようです。

$ heroku run rake assets:precompile RAILS_ENV=production

もしくは、以下でローカルでasset precompileし、git commit し
herokuにpushすれば良さそうです。

$ rake assets:precompile RAILS_ENV=production

こちら回答の参考にしたURLです。

アセットパイプライン
https://railsguides.jp/asset_pipeline.html

Herokuへのデプロイ時は常にproduction.rbの設定値でassets precompileされる
https://qiita.com/jnchito/items/a1833b48c3b47a955bdf#2-%E3%83%87%E3%83%97%E3%83%AD%E3%82%A4%E5%BE%8C%E3%81%AB%E5%88%A5%E9%80%94assets-precompile%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B

herokuでRailsアプリを公開する手順をゆっくり丁寧に。
https://workabroad.jp/posts/1164

投稿2020/01/10 18:49

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

babi-0105

2020/01/11 04:04

ありがとうございます!!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問