Devise Rails Bootstrap-注册模式 [英] Devise Rails Bootstrap - sign up modal
本文介绍了Devise Rails Bootstrap-注册模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试对我的Rails Devise Bootstrap登录使用&
I'm trying to use a modal for my Rails Devise Bootstrap sign in & sign up forms.
我尝试将views / devise / shared / registration_items中的链接更改为:
I have tried to alter the link in views/devise/shared/registration_items to:
<% if user_signed_in? %>
<li>
<%= link_to('Edit registration', edit_user_registration_path) %>
</li>
<% else %>
<li>
<%= link_to('Register', new_user_registration_path, data-toggle="modal" data-target="#myModal") %>
</li>
<% end %>
我在'link_to(Register ...')行中收到语法错误。请有人显示
I get a syntax error in the 'link_to(Register...' line. Please can someone show me how to make these forms work with bootstrap modals.
这是我的registration_new视图,如果有帮助的话:
Here is my registration_new view if it helps:
<!-- 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">×</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>
谢谢
推荐答案
您错过了一个逗号:
<%= link_to('Register', new_user_registration_path, data-toggle="modal", data-target="#myModal") %>
此外,您还应该将其他参数设为哈希,或者更好的方法是:
Also you should make extra parameters a hash, or better this:
<%= link_to 'Register', new_user_registration_path, 'data-toggle' => "modal", 'data-target' => "#myModal" %>
应该可以。 选中此
这篇关于Devise Rails Bootstrap-注册模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文