rails 5にてスマホ画面に対応したrailsアプリ(デプロイ先はheroku)を作っているのですがスマホ画面でユーザー登録画面(app/views/devise/registrations/new.html.erb)だけ表示されなくなると言うエラー。何度もリロードしてしまい表示できない。PCだと問題なく動く。
https://youtu.be/IyEtsPCMe0A リンク内容
app/views/devise/registrations/new.html.erb <h2>Sign up</h2> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> <div class="field"> <%= f.label :nickname %> <br /> <%= f.text_field :nickname, autofocus: true %> </div> <div class="field"> <%= f.label :email %><br /> <%= f.email_field :email, autofocus: true, autocomplete: "email" %> </div> <div class="field"> <%= f.label :password %> <% if @minimum_password_length %> <em>(<%= @minimum_password_length %> characters minimum)</em> <% end %><br /> <%= f.password_field :password, autocomplete: "new-password" %> </div> <div class="field"> <%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation, autocomplete: "new-password" %> </div> <div class="actions"> <%= f.submit "Sign up" %> </div> <% end %> <%= render "devise/shared/links" %>
いろいろ試しに試した結果、nickname とmail の入力欄が原因だと掴んだ。このコードでも同様のことが起きており、それ以外の入力欄余分なデザインは全て削除して、消去法で原因を掴んだが全てリロードはせずこのコードだけ同じ状態が発生したので間違いない。
<h2>Sign up</h2> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= f.text_field :nickname, autofocus: true %> <%= f.email_field :email, autofocus: true, autocomplete: "email" %> <div class="actions"> <%= f.submit "Sign up" %> </div> <% end %> <%= render "devise/shared/links" %>
念のためapplication.html.erbとgemファイルも載せておく
application.html.erb <!DOCTYPE html> <html> <head> <title>talkle</title> <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <link rel=”icon” type=”image/png” href=“/image/t-logo.png”> </head> <header class = header> <h1><%=link_to "talkle",root_path,method: :get%></h1> <%= form_tag(search_tweets_path,:method => 'get') do %> <%= text_field_tag :search %> <%= submit_tag 'Search', :name => nil %> <% end %> <% if user_signed_in? %> <div class="btn btn--orange btn--radius"> <%= link_to "マイページ", user_path(current_user) %> <%= link_to "ログアウト", destroy_user_session_path, method: :delete %> <%= link_to "投稿する", "/tweets/new", class: "post" %> </div> <% else %> <div class="btn btn--orange btn--radius"> <%= link_to "ログイン", new_user_session_path, class: "post" %> <%= link_to "新規登録", new_user_registration_path, class: "post" %> </div> <% end %> </header> <body class=view> <div class = space></div> <%= yield %> </body> </html>
source
1git_source(:github) { |repo| "https://github.com/#{repo}.git" } 2 3ruby '2.6.3' 4 5# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 6gem 'rails', '~> 5.2.1' 7# Use sqlite3 as the database for Active Record 8 9# Use Puma as the app server 10gem 'puma', '~> 3.11' 11# Use SCSS for stylesheets 12gem 'sass-rails', '~> 5.0' 13# Use Uglifier as compressor for JavaScript assets 14gem 'uglifier', '>= 1.3.0' 15# See https://github.com/rails/execjs#readme for more supported runtimes 16# gem 'mini_racer', platforms: :ruby 17 18# Use CoffeeScript for .coffee assets and views 19gem 'coffee-rails', '~> 4.2' 20# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 21gem 'turbolinks', '~> 5' 22# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 23gem 'jbuilder', '~> 2.5' 24# Use Redis adapter to run Action Cable in production 25# gem 'redis', '~> 4.0' 26# Use ActiveModel has_secure_password 27# gem 'bcrypt', '~> 3.1.7' 28 29# Use ActiveStorage variant 30# gem 'mini_magick', '~> 4.8' 31 32# Use Capistrano for deployment 33# gem 'capistrano-rails', group: :development 34 35# Reduces boot times through caching; required in config/boot.rb 36gem 'bootsnap', '>= 1.1.0', require: false 37 38group :development, :test do 39 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 41 gem 'sqlite3' 42end 43 44group :development do 45 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 46 gem 'web-console', '>= 3.3.0' 47 gem 'listen', '>= 3.0.5', '< 3.2' 48 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 gem 'spring' 50 gem 'spring-watcher-listen', '~> 2.0.0' 51end 52 53group :test do 54 # Adds support for Capybara system testing and selenium driver 55 gem 'capybara', '>= 2.15' 56 gem 'selenium-webdriver' 57 # Easy installation and use of chromedriver to run system tests with Chrome 58 gem 'chromedriver-helper' 59end 60 61group :production do 62 gem 'pg' , '~>0.18.4' 63end 64 65# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 66gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 67 68gem 'compass-rails', '3.1.0' 69gem 'sprockets', '3.7.2' 70gem 'hirb' 71gem 'hirb-unicode' 72gem 'devise' 73gem 'kaminari' 74group :production do 75 gem 'rails_12factor' 76end 77 78コード
あなたの回答
tips
プレビュー