Rails Devise Bootstrap Sign Up modal

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I'm trying to alter my devise registration view file to work with bootstrap modals.

I have followed the bootstrap instructions and slotted the form into the modal and linked it to the navbar menu. Now, when i click on 'Register' in my navbar. Nothing happens. The form doesn't go anywhere. I had this working when it was just a standard page view. Can anyone help? Thank you.

I am trying to follow this answer but am getting confused: Twitter Bootstrap Modal not popping up for user login

I have:

views/devise/shared/registration_items:

<% if user_signed_in? %>   <li>   <%= link_to('Edit registration', edit_user_registration_path) %>   </li> <% else %>   <li>   <%= link_to 'Register', new_user_registration_path, :remote => true, 'data-toggle' => "modal", 'data-target' => "#myModal", :method: 'get' %>     </li> <% end %> 

views/devise/registrations/new

<!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">   <div class="modal-dialog">     <div class="modal-content">       <div class="modal-header">         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>         <h4 class="modal-title" id="myModalLabel">Sign up</h4>       </div>       <div class="modal-body">            <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>              <%= f.error_notification %>               <div class="form-inputs">                <%= f.input :first_name, required: true, autofocus: true %>                <%= f.input :last_name, required: true, autofocus: true %>                <%= f.input :email, required: true, autofocus: true %>                <%= f.input :password, required: true %>                <%= f.input :password_confirmation, required: true %>                     </div>        </div>       <div class="modal-footer">         <div class="form-actions">               <%= f.button :submit, "Sign up" %>             </div>         <% end %>         <%= render "devise/shared/links" %>         </div>     </div>   </div> </div>  respond_to do |format|   format.js end 

I get a syntax error (syntax error, unexpected ':', expecting =>) on this line:

  <%= render 'devise/shared/registration_items' %> 

Please can anyone help. Thank you.

回答1:

There is a syntax error. Change to :method => 'get' or method: 'get' in the line below

'data-toggle' => "modal", 'data-target' => "#myModal", :method: 'get' 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!