Search code examples
ruby-on-railsdevise

Render Devise Edit as Partial View in Rails


I am currently developing a rails app. I have installed the devise gem and generated its view. I have a page as 'my profile' which allows the signed in user to edit the details that was entered on sign up. However, i want to render devise/registrations/edit inside tabs that i have created using bootstrap in my profile page.

Currently my profile page looks something like this.

<ul class="nav nav-tabs" id="myTab" role="tablist">
  <li class="nav-item">
    <a class="nav-link active" id="profile-tab" data-toggle="tab" href="#" role="tab" 
    aria-controls="profile" aria-selected="true">
    </a>
  </li>
</ul>

<div class="tab-content" id="myTabContent">
  <div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
  //
  //
  //**This is where I want to add the registrations/edit from devise.**
  // 
  //
  </div>
</div>

Solution

  • You do it using the following snipppet:

    <%= render template: "devise/registrations/edit" %>
    

    So your template becomes:

    <ul class="nav nav-tabs" id="myTab" role="tablist">
      <li class="nav-item">
        <a class="nav-link active" id="profile-tab" data-toggle="tab" href="#" role="tab" 
        aria-controls="profile" aria-selected="true">
        </a>
      </li>
    </ul>
    
    <div class="tab-content" id="myTabContent">
      <div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
      //
      //
      //**This is where I want to add the registrations/edit from devise.**
      <%= render template: "devise/registrations/edit" %>
      // 
      //
      </div>
    </div>