将设计sign_in形式转换成Twitter Bootstrap模态 [英] Getting devise sign_in form into Twitter Bootstrap Modal

查看:121
本文介绍了将设计sign_in形式转换成Twitter Bootstrap模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我想使用twitter bootstrap模式来显示设计登录表单。

Okay, so I want to use the twitter bootstrap modal to display the devise sign-in form.

我基于我的维基文章的代码在这里:
https:// github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app

I am basing my code of the wiki article here: https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app

我的应用程序布局文件中有以下标记

I have the below markup in my application layout file

<div class="modal fade" id="loginModal">
  <div class="modal-header">
    <button class="close" data-dismiss="modal">×</button>
    <h3>Sign In</h3>
  </div>
  <div class="modal-body">
    <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-horizontal'}) do |f| %>
          <div class="inputs">
            <%= f.input :email, :required => false, :autofocus => true %>
            <%= f.input :password, :required => false %>
            <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
          </div>
  </div>
    <div class="modal-footer">
        <%= f.button :submit, "Sign in", :class => 'btn btn-primary', :data => { :dismiss => "modal"} %>
        <% end %>
    </div>
</div>

而且,按照wiki中的建议,将以下内容添加到应用程序帮助文件

And, following the advice in the wiki, added the following to the application helper file

def resource_name
  :user
end

def resource
  @resource ||= User.new
end

def devise_mapping
 @devise_mapping ||= Devise.mappings[:user]
end

然而,它不起作用。模式解雇,没有任何反应。页面不会去任何地方或做任何事情。去实际的登录页面工作,但提交的模式不是。建议?

It however, does not work. The modal dismisses and nothing happens. The page doesn't go anywhere or do anything. Going to the actual sign-in page works, but submitted the modal does not. Suggestions?

推荐答案

这是最终工作的代码

<%= simple_form_for(:user, :url => user_session_path) do |f| %>

这篇关于将设计sign_in形式转换成Twitter Bootstrap模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆