Ruby on Rails チュートリアル 22日目
今日も前回と同じところで躓いていました。「railsチュートリアル13章 エラー」と検索して、エラーを修正した人たちのサイトを参考にして修正できないかと思い色んなサイトを確認しましたが、自分の詰まっているところの後のものばかりで、参考にすることができませんでした。13.3.4 マイクロポストを削除するが終わったところまで戻してからもう一度13.3.5 フィード画面のマイクロポストをテストするの内容を書き直しましたが、同じエラー文を吐き出すだけでした
エラー文
rails t
Running via Spring preloader in process 12181
Run options: --seed 21615
# Running:
.............................E....................
Finished in 1.756059s, 28.4728 runs/s, 150.3366 assertions/s.
1) Error:
MicropostsInterfaceTest#test_micropost_interface:
ActionView::Template::Error: Missing partial shared/_micropost_form with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
* "/home/ec2-user/environment/sample_app/app/views"
app/views/static_pages/home.html.erb:8:in `_app_views_static_pages_home_html_erb___3245317371641121828_58712980'
test/integration/microposts_interface_test.rb:11:in `block in <class:MicropostsInterfaceTest>'
50 runs, 264 assertions, 0 failures, 1 errors, 0 skips
require 'test_helper'
class MicropostsInterfaceTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
end
test "micropost interface" do
log_in_as(@user)
get root_path
assert_select 'div.pagination'
# 無効な送信
assert_no_difference 'Micropost.count' do
post microposts_path, params: { micropost: { content: "" } }
end
assert_select 'div#error_explanation'
# 有効な送信
content = "This micropost really ties the room together"
assert_difference 'Micropost.count', 1 do
post microposts_path, params: { micropost: { content: content } }
end
assert_redirected_to root_url
follow_redirect!
assert_match content, response.body
# 投稿を削除する
assert_select 'a', text: 'delete'
first_micropost = @user.microposts.paginate(page: 1).first
assert_difference 'Micropost.count', -1 do
delete micropost_path(first_micropost)
end
# 違うユーザーのプロフィールにアクセス (削除リンクがないことを確認)
get user_path(users(:archer))
assert_select 'a', text: 'delete', count: 0
end
end
test/integration/microposts_interface_test.rbに上の内容を書く前までは、エラーが発生することがなかったので原因はtest/integration/microposts_interface_test.rbにあるのではないかと推測しましたが、これはチュートリアルに書いてあるものと全く同じものなので、修正箇所がどこにあるのかもわかりません。
このままわからないようならば、明日もう一度ブランチごと書いてみようと思います。
追記
原因は、マイクロソフト投稿フォームのパーシャルのファイル名の_micropost_form.html.erbが、_micropost_from.html.erbになっていることでした。
Author And Source
この問題について(Ruby on Rails チュートリアル 22日目), 我々は、より多くの情報をここで見つけました https://qiita.com/flandrescarlet237/items/88a728afca58b2cea91e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .