0

Hi sir in rails 4 while using form_for also getting above error in google i read about this and follow that but even also i am getting same error if i disable in application controller and added protect_from_forgery with: :null_session it is working but when i submit the form_for form i am getting params missing or params should not empty . i refered this link i refered linkeven also not working

Error in the log file Processing by UsersController#create as HTML Can't verify CSRF token authenticity

code view

<%= form_for @user  do |f| %>
 <p>
    <%= f.label :first_name %><br />
    <%= f.text_field :first_name %>
  </p>
 <p>
    <%= f.label :last_name %><br />
    <%= f.text_field :last_name %>
  </p>
  <p>
    <%= f.label :gender %><br />
    <%= f.text_field :gender %>
  </p>

= f.fields_for :address do |p| %>
   <p>
    <%= p.label :city %><br />
    <%= p.text_field :city %>
  </p>
    <p>
    <%= p.label :state %><br />
    <%= p.text_field :state %>
  </p>
 <p>
    <%= p.label :country %><br />
    <%= p.text_field :country %>
  </p>
   <p>
    <%= p.label :postal_code %><br />
    <%= p.text_field :postal_code %>
  </p>
<% end %>
  <p><%= f.submit %></p>
<% end %>

if set protect_from_forgery with: :null_session and if submit the form than i will getting one more error

param is missing or the value is empty:

userActionController::ParameterMissing (param is missing or the value is empty: user):

Community
  • 1
  • 1

0 Answers0