We are proceeding with the rails tutorial.
8.1.4 Display flash message
I did the above item, but two flash messages appear as shown below.
I'm going to do the contents as described in the tutorial, but is something wrong?
If there is something that can be thought of, it would be helpful if you could tell me.
Contents that are likely to be relevant in the various descriptions that have been set are listed below.
The view file (view/sessions/new.html.erb) is as follows.
<% provide (: title, "Log in")%> <h1>Log in</h1> <div> <div> <% = form_for (: session, url: login_path) do | f |%> <% = f.label: email%> <% = f.email_field: email, class: 'form-control'%> <% = f.label: password%> <% = f.password_field: password, class: 'form-control'%> <% = f.submit "Log in", class: "btn btn-primary"%> <% end%> <p>New user?<% = link_to "Sign up now!", signup_path%></p> </div> </div>
The session controllers (controllers/sessions_controller) are as follows.
class SessionsController<ApplicationController def new end def create user = User.find_by (email: params [: session] [: email] .downcase) if user&&user.authenticate (params [: session] [: password]) # Redirect to user info page after user login else flash.now [: danger] = 'Invalid email/password combination' render 'new' end end def destroy end end
The route (config/routes.rb) is as follows.
Rails.application.routes.draw do get 'sessions/new' get 'users/new' root 'static_pages # home' get '/ help', to: 'static_pages # help' get '/ about', to: 'static_pages # about' get '/ contact', to: 'static_pages # contact' get '/ signup', to: 'users # new' post '/ signup', to: 'users # create' get '/ login', to: 'sessions # new' post '/ login', to: 'sessions # create' delete '/ logout', to: 'sessions # destroy' resources: users end
Please let me know if you have any other necessary information.
Answer # 1
There were two lines in the application.html that spit out the flash.
(The contents of the exercises were left behind.)
- ruby on rails 5 - rubyonrails tutorial chapter 10 assert error
- ruby - rails tutorial 13 chapter 1329 i can't understand the cause because the test cannot be passed
- ruby - rails tutorial chapter 12 1233 test does not pass
- ruby on rails - rails tutorial rails 60 chapter 1 first, can't install yarn
- ruby - rails tutorial chapter 11 i can't push to _heroku
- ruby - i want to know why the rails tutorial chapter 9 tests fail
- ruby - rails tutorial chapter 13 can't deploy to heroku with argumenterror
- ruby - rails tutorial chapter 10: an error is issued if the admin? method is not defined
- ruby on rails - tutorial chapter 5 about the header partial
- ruby - rails tutorial please let me ask about email resetting
- ruby on rails - rails tutorial about git config settings
- [ruby on rails] flash message is not displayed when updating tweets
- ruby - rails tutorial chapter 11 error with different redirect destination and error with flash display
- ruby on rails - rails tutorial: user registration failure
- ruby - in the rails tutorial
- ruby - rails tutorial please explain the syntax of the update_attribute method line in chapter 9
- ruby - unable to deploy (in rails tutorial chapter 1)
- ruby on rails 6 - rails tutorial extension function favorite function cannot be implemented
- ruby - i would like to know how to solve the error that occurred while implementing rails tutorial chapter 10
- ruby on rails - bitbucket push doesn't work (rails tutorial)
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved