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

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

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

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

Ruby on Rails

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

2回答

2396閲覧

localhost:3000へアクセスしても画面が表示されない

makoxti

総合スコア32

Ruby

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

Ruby on Rails

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/07/29 12:53

編集2021/07/29 14:29

ruby初学者です。
現在Udemyで購入したRuby on Railsの講座を見ながら自分も手を動かして勉強しているのですが、動画通りに画面表示ができなくて困っています。
コンソールに出力されているキーワードでググったのですが、解決できず。。。
初歩的な内容なのかもしれませんが、わかる方がいたらご教授頂けると幸いです。
Dockerを使用しています。
gitのリポジトリは以下となります。
https://github.com/makoxty/ruby/tree/master/myapp

ターミナル実行コマンド
docker-compose run web rails new . --force --no-deps --database=postgresql
ocker-compose build

config/database.ymlを以下に書き換え
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
#####追加#####
host: db
username: postgres
passowrd:
#############

development:
<<: *default
database: myapp_development

test:
<<: *default
database: myapp_test

production:
<<: *default
database: myapp_production
username: myapp
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>

DB作成コマンド
docker-compose run web rake db:create

docker-compose up -d

・コンソール
web_1 | Use Ctrl-C to stop
web_1 | Started GET "/" for 172.21.0.1 at 2021-07-29 12:32:01 +0000
web_1 | Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
web_1 | Processing by BoardsController#index as HTML
web_1 | Rendering boards/index.html.erb within layouts/application
web_1 | Rendered boards/index.html.erb within layouts/application (Duration: 4.4ms | Allocations: 235)
web_1 | malloc(): invalid size (unsorted)
web_1 exited with code 133
db_1 | 2021-07-29 12:36:39.708 UTC [45] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted

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

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

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

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

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

zembutsu

2021/07/29 13:20

Docker Composeをお使いと思いますので、どのような docker-compose.yaml を使って、どのようにコマンドを実行し、どのような結果を得られたいのかをご質問内容に書かれれば、何かしらアドバイスができるかもしれません。 (ご質問内容だけでは大変恐縮なのですがアドバイスのしようがなく、本来はその講座の教材を提供されている方に質問されるのが筋ではと思います)
zembutsu

2021/07/29 13:22

せめて、その動画のURLをご提示いただければ、確認のしようがあるかもしれません。
makoxti

2021/07/29 13:31

zembutsu様 コメントありがとうございます。 仰る通り教材投稿者に質問するのが筋ということは認識しているのですが、数年前の講座なのでいつ回答貰えるのかわからないのでこちらで質問させて頂きました。 ファイルの中身も記載したかったのですが、文字数制限があるため記載できませんでした。 講座は下記となります。 https://www.udemy.com/course/rails-kj/learn/lecture/9520642#questions ターミナルで実行したコマンドは以下となります。 docker-compose run web rails new . --force --no-deps --database=postgresql docker-compose build config/database.ymlを以下に書き換え default: &default adapter: postgresql encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> #####追加##### host: db username: postgres passowrd: ############# development: <<: *default database: myapp_development test: <<: *default database: myapp_test production: <<: *default database: myapp_production username: myapp password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %> docker-compose run web rake db:create docker-compose up ・docker-compose.yaml version: '3' services: db: image: postgres volumes: - ./tmp/db:/var/lib/postgresql/data environment: - POSTGRES_PASSWORD=password web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/myapp ports: - "3000:3000" depends_on: - db ・boards_controller.rb class BoardsController < ApplicationController def index end end ・Gemfile source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.6' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.3' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 4.1' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 4.0' # 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.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false #bootstrap4 gem 'bootstrap', '~> 4.1.1' gem 'jquery-rails' gem 'mini_racer' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.2' # 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 group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] ・index.html.erb <div class="d-flex align-items-center"> <h1>掲示板一覧</h1> <div class="ml-auto boards__linkBox"> <a class="btn btn-outline-dark">新規作成</a> </div> </div> <table class="table table-hover boards__table"> <thead class="thead-dark"> <tr> <th>ID</th> <th>タイトル</th> <th>作成者</th> <th>作成日時</th> <th>更新日時</th> </tr> </thead> <tbody> <tr> <th>1</th> <td>雑談掲示板</td> <td>Taro</td> <td>2018年4月1日</td> <td>2018年4月15日</td> </tr> <tr> <th>2</th> <td>雑談掲示板2</td> <td>Ken</td> <td>2018年4月1日</td> <td>2018年4月15日</td> </tr> </tbody> </table>
guest

回答2

0

自己解決

色々ググってみたが、解決せず

投稿2021/07/30 14:14

makoxti

総合スコア32

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

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

0

よく見たらDocker使ってるんですね。ということで、下記の回答は意味が無さそうです。docker-compose.ymlなりDockerfileなりの情報がないと回答は出てこないと思いますので、そちらの情報を質問文に追記してください。

Dockerを使用しているという情報は重要なので、かならず質問文に含めた方が良いです。


Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1

となってるので、とりあえず 127.0.0.1:3000 でアクセスしてみたらどうですか?
アクセスできる可能性はあると思います。

参考)
https://qiita.com/1ain2/items/194a9372798eaef6c5ab

できなければ違うログが出ると思うので、質問文に追記してください。

投稿2021/07/29 13:12

編集2021/07/29 13:46
AbeTakashi

総合スコア4594

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

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

makoxti

2021/07/29 14:27

コメントありがとございます。 申し訳ありません、Dockerを使用している旨を追記します。 gitにソースファイルをpushしました。 リポジトリは下記となります。 https://github.com/makoxty/ruby/tree/master/myapp
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問