0

I’m trying to split my rails devise edit form into 3 pages. But when I hit the submit button nothing happens and nothing gets saved. I have a very long sign up process, so that's why, I want to split the edit page.

Any help would be much appreciated.

This is from the log, when I hit the submit button

Started PATCH "/userprofiles/clinic_info" for ::1 at 2020-02-21 08:16:13 +0100
Processing by UserprofilesController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"fYdVH9aY3XfQ+Fu639zhEsvrxRwYtIeYacqrKowDDlPu3r6iuXZOalFahSJ61peVBawf0DioVu+arrJzJK5M9A==", "user"=>{"clinic_name"=>"Kaspers Zoness", "clinic_address"=>"Krebsen 99", "clinic_zip_code"=>"5700", "clinic_city"=>"Svendborg", "clinic_municipality"=>"Svendborg", "clinic_about"=>"Jeg trykker på fødderne", "clinic_mail"=>"[email protected]", "clinic_phone"=>"24210886", "clinic_website"=>""}, "commit"=>"Gem"}
No template found for UserprofilesController#update, rendering head :no_content
Completed 204 No Content in 65ms (ActiveRecord: 0.0ms)

I have created 3 edit pages in this folder views/userprofiles

user_info.html.erb
clinic_info.html.erb
practitioner_info.html.erb

In my routes I have created these routes for the new files and for the update

  get "userprofiles/user_info" => "userprofiles#user_info", as: "user_info"
  get "userprofiles/clinic_info" => "userprofiles#clinic_info", as: "clinic_info"
  get "userprofiles/practitioner_info" => "userprofiles#practitioner_info", as: "practitioner_info"


  patch "userprofiles/user_info" => "userprofiles#update"
  patch "userprofiles/clinic_info" => "userprofiles#update"
  patch "userprofiles/practitioner_info" => "userprofiles#update"

I’ve created this new controller for the purpose

class UserprofilesController < ApplicationController
# fill the methods as you need, you can always get the user using current_user

def user_info
end

def clinic_info
end

def practitioner_info
end

def update
end

end

This is my form for the clinic_info page

            <div class="content clinic">
              <h2 class="page-title">Generel information</h2>       
                <div class="basic-section">

                    <%= form_for(current_user, url: clinic_info_path) do |f| %>

                    <div class="field text-field">
                        <%= f.text_field :clinic_name, autofocus: true, autocomplete: "Klinikkens navn", placeholder: "Klinikkens navn"  %>

                    </div>
                    <div class="field text-field">
                      <%= f.text_field :clinic_address, autofocus: true, autocomplete: "Adresse", placeholder: "Adresse" %>
                    </div>
                    <div class="field-group location-group">
                      <div class="field text-field">
                        <%= f.text_field :clinic_zip_code, autofocus: true, autocomplete: "Postnr.", placeholder: "Postnr." %>
                      </div>
                      <div class="field text-field">
                        <%= f.text_field :clinic_city, autofocus: true, autocomplete: "By", placeholder: "By" %>
                      </div>
                      <div class="field text-field">
                        <%= f.text_field :clinic_municipality, autofocus: true, autocomplete: "Kommune", placeholder: "Kommune" %>
                      </div>
                    </div>          
                </div>
                <div class="about-section">
                  <div class="field text-field">
                      <%= f.text_field :clinic_about, :as => :text, :input_html => { 'rows' => 5}, autofocus: true, autocomplete: "Om klinikken", placeholder: "Om klinikken" %>
                  </div>
                </div>
                <div class="field-group contact-section">
                  <div class="field text-field">
                    <%= f.text_field :clinic_mail, input_html: { autocomplete: 'email' }, autofocus: true, placeholder: "E-mail" %>
                  </div>
                  <div class="field text-field">
                    <%= f.text_field :clinic_phone, autofocus: true, autocomplete: "Tlf. nr.", placeholder: "Tlf. nr." %>
                  </div>
                  <div class="field text-field">
                    <%= f.text_field :clinic_website, autofocus: true, autocomplete: "Hjemmeside", placeholder: "Hjemmeside" %>
                  </div>
                </div>
                <div class="btn-container">
                  <%= f.submit "Save", :class => 'btn blue'  %>                 
               </div>
              <% end %>
          </div> 
1

1 Answer 1

0

Your update method in the UserprofilesController doesn't do anything.

It receives the params from the form that is submitted, but you also need to write code to do something with it(updating the user_profile).

It would look something like:

def update
  if current_user.update(user_params)
    redirect_to #some_path_here
  else
    #do something else if it fails
  end
end

Then you also need to define the user_params in a private section like:

def user_params
  params.require(:user).permit(:clinic_name, :clinic_address, #etc)
end
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.