前提・実現したいこと
チャットサイトをrailsで作ろうとしているのですが固定のチャットルームを作る為
seedで初期データを先に書き読み込む事で作る事にしました。
ローカル環境では上手くはまりました。
しかし、herokuでデプロイして heroku run rails db:seedのコマンド
を打ち込んでそれぞれの場所に飛ぼうとするとそのページはありませんと言われてしまいます。
(順番にseed.rbで作っているのでそのidに対応したルートを<a href>で選んで飛ばしています。)
該当のソースコード
ruby
1User.create!( 2 nickname: "staff", 3 team_id: 11, 4 favorite_player: "種市", 5 introduction: "test", 6 email: 'test@test.com', 7 password: 'aaa111' 8) 9Room.create!( 10 name: "読売ジャイアンツ専用チャット", 11 content: "test", 12 user_id: "1", 13 official: "Yes" 14) 15Room.create!( 16 name: "横浜DeNAベイスターズ専用チャット", 17 content: "test", 18 user_id: 1, 19 official: "Yes" 20) 21Room.create!( 22 name: "阪神タイガース専用チャット", 23 content: "test", 24 user_id: 1, 25 official: "Yes" 26) 27Room.create!( 28 name: "ヤクルトスワローズ専用チャット", 29 content: "test", 30 user_id: 1, 31 official: "Yes" 32) 33Room.create!( 34 name: "中日ライオンズ専用チャット", 35 content: "test", 36 user_id: 1, 37 official: "Yes" 38) 39Room.create!( 40 name: "広島カープ専用チャット", 41 content: "test", 42 user_id: 1, 43 official: "Yes" 44) 45Room.create!( 46 name: "ソフトバンクホークス専用チャット", 47 content: "test", 48 user_id: "1", 49 official: "Yes" 50) 51Room.create!( 52 name: "西武ライオンズ専用チャット", 53 content: "test", 54 user_id: 1, 55 official: "Yes" 56) 57Room.create!( 58 name: "千葉ロッテマリーンズ専用チャット", 59 content: "test", 60 user_id: 1, 61 official: "Yes" 62) 63Room.create!( 64 name: "楽天イーグルス専用チャット", 65 content: "test", 66 user_id: 1, 67 official: "Yes" 68) 69Room.create!( 70 name: "オリックスバファローズ専用チャット", 71 content: "test", 72 user_id: 1, 73 official: "Yes" 74) 75Room.create!( 76 name: "日本ハムファイターズ専用チャット", 77 content: "test", 78 user_id: 1, 79 official: "Yes" 80)
erb
1<div class="center-contents"> 2 <h2 class="center-title">ようこそ!</h2> 3</div> 4<div class="center-list"> 5 <ul class="s-team"> 6 <%=image_tag "s-team.png", class: "spteam"%> 7 <li class="content"><%=image_tag "giants_icon.png", class:"icon"%> <a href="/rooms/1/messages">読売ジャイアンツ</a></li> 8 <li class="content"><%=image_tag "baystars_icon.png", class:"icon"%> <a href="/rooms/2/messages">横浜DeNAベイスターズ</a></li> 9 <li class="content"><%=image_tag "tigers_icon.png", class:"icon"%> <a href="/rooms/3/messages">阪神タイガース</a></li> 10 <li class="content"><%=image_tag "swallows_icon.png", class:"icon"%> <a href="/rooms/4/messages">ヤクルトスワローズ</a></li> 11 <li class="content"><%=image_tag "dragons_icon.png", class:"icon"%> <a href="/rooms/5/messages">中日ライオンズ</a></li> 12 <li class="content"><%=image_tag "carp_icon.png", class:"icon"%> <a href="/rooms/6/messages">広島カープ</a></li> 13 </ul> 14 <ul class="p-team"> 15 <%=image_tag "p-team.png", class: "spteam"%> 16 <li class="content"><%=image_tag "hawks_icon.png", class:"icon"%> <a href="/rooms/7/messages">ソフトバンクホークス</a></li> 17 <li class="content"><%=image_tag "lions_icon.png", class:"icon"%> <a href="/rooms/8/messages">西武ライオンズ</a></li> 18 <li class="content"><%=image_tag "marines_icon.png", class:"icon"%> <a href="/rooms/9/messages">千葉ロッテマリーンズ</a></li> 19 <li class="content"><%=image_tag "eagles_icon.png", class:"icon"%> <a href="/rooms/10/messages">楽天イーグルス</a></li> 20 <li class="content"><%=image_tag "buffaloes_icon.png", class:"icon"%> <a href="/rooms/11/messages">オリックスバファローズ</a></li> 21 <li class="content"><%=image_tag "fiters_icon.png", class:"icon"%> <a href="/rooms/12/messages">日本ハムファイターズ</a></li> 22 </ul> 23</div>
ログ Running rake db:seed on ⬢ baseball-chat2020... up, run.2551 (Free) DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use `ActiveSupport::LoggerSilence` instead (called from <top (required)> at /app/config/application.rb:7) (2.1ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 (2.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC (2.0ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 (2.9ms) BEGIN User Exists? (2.9ms) SELECT 1 AS one FROM `users` WHERE `users`.`email` = BINARY 'test@test.com' LIMIT 1 User Create (3.0ms) INSERT INTO `users` (`nickname`, `team_id`, `favorite_player`, `introduction`, `email`, `encrypted_password`, `created_at`, `updated_at`) VALUES ('staff', 11, '種市', 'test', 'test@test.com', '$2a$12$1XSOSKPFJKSnfL25leecQu1w2eDuo07i7itshhkBqyEd.YROCJiY2', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (8.4ms) COMMIT (2.0ms) BEGIN User Load (2.1ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (2.0ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('読売ジャイアンツ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (9.2ms) COMMIT (1.9ms) BEGIN User Load (1.9ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (2.0ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('横浜DeNAベイスターズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (8.2ms) COMMIT (2.0ms) BEGIN User Load (2.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (2.1ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('阪神タイガース専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (10.6ms) COMMIT (1.9ms) BEGIN User Load (1.9ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (1.9ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('ヤクルトスワローズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (9.2ms) COMMIT (1.8ms) BEGIN User Load (1.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (1.8ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('中日ライオンズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (9.7ms) COMMIT (2.0ms) BEGIN User Load (2.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (1.9ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('広島カープ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (11.6ms) COMMIT (1.9ms) BEGIN User Load (2.1ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (3.1ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('ソフトバンクホークス専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (11.9ms) COMMIT (2.0ms) BEGIN User Load (1.9ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (1.8ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('西武ライオンズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (8.9ms) COMMIT (1.9ms) BEGIN User Load (2.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (2.0ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('千葉ロッテマリーンズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (8.7ms) COMMIT (1.9ms) BEGIN User Load (1.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (1.9ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('楽天イーグルス専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (8.9ms) COMMIT (2.3ms) BEGIN User Load (2.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (2.0ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('オリックスバファローズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (9.9ms) COMMIT (2.2ms) BEGIN User Load (1.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Room Create (2.0ms) INSERT INTO `rooms` (`name`, `content`, `user_id`, `official`, `created_at`, `updated_at`) VALUES ('日本ハムファイターズ専用チャット', 'test', 1, 'Yes', '2020-09-04 04:48:39', '2020-09-04 04:48:39') (11.3ms) COMMIT
補足情報(FW/ツールのバージョンなど)
rails 6.0.0
回答1件
あなたの回答
tips
プレビュー