Home>
I want to achieve
I want to eliminate errors around the form.
problemIt worked fine in my local environment, but after deploying to heroku I started getting an error.
When I go to the signup page, I get "We're sorry, but something went wrong."
When I checked the log, it was as follows.
It seems that the form is not good, but I don't know what is wrong.
INFO-: [1cda6211-bd91-414a-a944-0c90c5dc8c31] Completed 500 Internal Server Error in 176ms (ActiveRecord: 42.3ms)
FATAL-: [1cda6211-bd91-414a-a944-0c90c5dc8c31]
FATAL-: [1cda6211-bd91-414a-a944-0c90c5dc8c31] ActionView :: Template :: Error (undefined method `last_name'for #<User: 0x00007f4bd0e41240>):
FATAL-: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 6:<% = form_for (@user) do | f |%>
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 7:<% = render'shared/error_messages'%>
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 8:<% = f.label: last_name, "Last name"%>
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 9:<% = f.text_field: last_name, class:'form-control'%>
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 10:
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 11:<% = f.label: first_name, "name"%>
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] 12:<% = f.text_field: first_name, class:'form-control'%>
FATAL-: [1cda6211-bd91-414a-a944-0c90c5dc8c31]
FATAL-: [1cda6211-bd91-414a-a944-0c90c5dc8c31] app/views/users/new.html.erb: 9: in `block in _app_views_users_new_html_erb__3434323429866559602_69981802564760'
app [web.1]: [1cda6211-bd91-414a-a944-0c90c5dc8c31] app/views/users/new.html.erb: 6: in `_app_views_users_new_html_erb__3434323429866559602_69981802564760'
Corresponding code
6<% = form_for (@user) do | f |%>
7<% = render'shared/error_messages'%>
8<% = f.label: last_name, "Last name"%>
9<% = f.text_field: last_name, class:'form-control'%>
Ten
11<% = f.label: first_name, "before"%>
12<% = f.text_field: first_name, class:'form-control'%>
13
14<% = f.label: email, "Email address"%>
15<% = f.email_field: email, class:'form-control'%>
16
17<% = f.label: tel, "phone number"%>
18<% = f.text_field: tel, class:'form-control'%>
19
20<% = f.label: password, "password"%>
21<% = f.password_field: password, class:'form-control'%>
twenty two
23<% = f.label: password_confirmation, "password confirmation"%>
24<% = f.password_field: password_confirmation, class:'form-control'%>
twenty five
26<% = f.submit "Registration", class: "signup_btn"%>
27<% end%>
users_controller.rb
def new
@user = User.new
end
def create
@user = User.new (user_params)
if @ user.save
@ user.send_activation_email
# UserMailer.account_activation (@user) .deliver_now
flash [: info] = "Please check your email to activate your account."
redirect_to root_url
else else
render "new"
end
end
private
def user_params
params.require (: user) .permit (: last_name,: first_name,: email,: tel,: password,: password_confirmation)
end
-
Answer # 1
Related articles
- when i open heroku, i get we're sorry, but something went wrong
- ruby - about initial data of seedrb on heroku
- ruby - rails heroku deploy error
- ruby - error when deploying on heroku
- ruby on rails - rails heroku typeerror (no implicit conversion of nil into string) issue
- ruby on rails - how to resolve argumenterror
- ruby - heroku deploy error
- ruby on rails - how to always start heroku (original domain)
- mysql - deploy ruby app to heroku
- ruby - i can't add sendgrid to heroku so i can't use devise's email function
- ruby - draw bootstrap correctly on heroku
- ruby on rails - images uploaded on heroku disappear over time amazon s3
- ruby on rails - i want to resolve nameerror in micropostscontroller # search
- ruby - unable to create app database on heroku
- ruby on rails - i can't install heroku cli on ubuntu [error during apt-get update? ]
- i want to resolve the error statement (ruby on rails)
- ruby - i want to reset the heroku database!
- ruby - failed to deploy to heroku i would like to ask for your help (the cause is bundler ???)
- ruby on rails - heroku run rails db: migrate an error occurs in heroku run rails db: migrate
Related questions
- ruby - [rails] page transition is not correct after deploying heroku (we're sorry, but something went wrong)
- ruby - deployment error on heroku
- ruby - i get an error after deploying on heroku
- ruby - tags are not saved in the database
- ruby - the image is displayed as strange characters in rails
- ruby - the top screen is displayed at http: // localhost: 3000/users/sign_in
- ruby - i don't understand the meaning of "redis:" described in yml file etc when dealing with redis in rails
- html - about boot strap free introduction
- ruby - i don't feel that the sql issued by rails has a different format from the sql that i usually write
- ruby - validation does not work
We received an answer from hatsu.
I haven't migrated to heroku.