Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 使用Rails 4上的haml将引导程序3集成到简单形式中_Ruby On Rails 4_Twitter Bootstrap 3_Simple Form - Fatal编程技术网

Ruby on rails 4 使用Rails 4上的haml将引导程序3集成到简单形式中

Ruby on rails 4 使用Rails 4上的haml将引导程序3集成到简单形式中,ruby-on-rails-4,twitter-bootstrap-3,simple-form,Ruby On Rails 4,Twitter Bootstrap 3,Simple Form,我想我有一个足够简单的问题,但似乎找不到答案 我已经使用了bootstrap3signinformhtml/CSS/Javascript,现在正在对其进行转换,以便它与我现有的haml/simple\u form/rails4应用程序一起工作 我的原始代码是 = simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| .form-inputs

我想我有一个足够简单的问题,但似乎找不到答案

我已经使用了bootstrap3signinformhtml/CSS/Javascript,现在正在对其进行转换,以便它与我现有的haml/simple\u form/rails4应用程序一起工作

我的原始代码是

  = simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
  .form-inputs
    = f.input :email, :required => false, :autofocus => true
    = f.input :password, :required => false
    = f.input :remember_me, :as => :boolean if devise_mapping.rememberable?
  .form-actions
    = f.button :submit, "Sign in"
= render "devise/shared/links"
我正试图将其纳入新的代码中

.container  
  #loginbox.mainbox.col-md-6.col-md-offset-3.col-sm-8.col-sm-offset-2{style: "margin-top:50px;"}
    .panel.panel-info
      .panel-heading
        .panel-title Sign In
        %div{style: "float:right; font-size: 80%; position: relative; top:-10px"}
          = link_to "Forgot your password?", new_password_path(resource_name)
      .panel-body{style: "padding-top:30px"}
        #login-alert.alert.alert-danger.col-sm-12{style: "display:none"}
        %form#loginform.form-horizontal{role: "form"}
          .input-group{style: "margin-bottom: 25px"}
            %span.input-group-addon
              %i.glyphicon.glyphicon-user
            %input#login-username.form-control{name: "username", placeholder: "username or email", type: "text", value: ""}/
          .input-group{style: "margin-bottom: 25px"}
            %span.input-group-addon
              %i.glyphicon.glyphicon-lock
            %input#login-password.form-control{name: "password", placeholder: "password", type: "password"}/
          .input-group
            .checkbox
              %label
                %input#login-remember{name: "remember", type: "checkbox", value: "1"}/
                Remember me
          .form-group{style: "margin-top:10px"}
            / Button
            .col-sm-12.controls
              = link_to session_path(resource_name) do
                #btn-login.btn.btn-success Login
我找到了忘记的密码位,因为这只是一个简单的抛出链接以替换%a标记的情况,但我被简单的表单资源难住了。。。一点

特别是像这样的线

= f.input :password, label: false, :required => false
如何添加引导行中的内容

%input#login-password.form-control{name: "password", placeholder: "password", type: "password"}/
因此,我想将div类“input”、id“login password”和类“form control”添加到我的简单表单代码中。我尝试了两种方法:html=>{:class=>'form horizontal'}和input_html:{class:'special'},但它似乎不起作用,Github上的解释也没有指定在将多个类、ID等应用于一行代码时规则是否会更改

自从发布这个问题以来,我已经完成了一半的转换,我当前的代码如下

    .container  
  #loginbox.mainbox.col-md-6.col-md-offset-3.col-sm-8.col-sm-offset-2{style: "margin-top:50px;"}
    .panel.panel-info
      .panel-heading
        .panel-title Sign In
        %div{style: "float:right; font-size: 80%; position: relative; top:-10px"}
          = link_to "Forgot your password?", new_password_path(resource_name)
      .panel-body{style: "padding-top:30px"}
        #login-alert.alert.alert-danger.col-sm-12{style: "display:none"}
        = simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
          %form#loginform.form-horizontal{role: "form"}
            .input-group{style: "margin-bottom: 25px"}
              %span.input-group-addon
                %i.glyphicon.glyphicon-user
              = f.input :email, :required => false, label: false, :autofocus => true, placeholder: '@usgboral.com', input_html: { class: 'form-control' }
            .input-group{style: "margin-bottom: 25px"}
              %span.input-group-addon
                %i.glyphicon.glyphicon-lock
              = f.input :password, label: false, :required => false
            .input-group
              .checkbox
                %label
                %input#login-remember{name: "remember", type: "checkbox", value: "1"}/
                = f.input :remember_me, :html => {:id => 'login-remember' }, :as => :boolean if devise_mapping.rememberable?
                Remember me
            .form-group{style: "margin-top:10px"}
              .form-actions.col-sm-12.controls
                = f.button :submit, "Login", :html => { :id => 'btn-login', :class => 'btn btn-success' }
.container  
  #loginbox.mainbox.col-md-6.col-md-offset-3.col-sm-8.col-sm-offset-2{style: "margin-top:50px;"}
    .panel.panel-info
      .panel-heading
        .panel-title Login
        %div{style: "float:right; font-size: 80%; position: relative; top:-10px"}
          = link_to "Forgot your password?", new_password_path(resource_name)
      .panel-body{style: "padding-top:30px"}
        #login-alert.alert.alert-danger.col-sm-12{style: "display:none"}
        = simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
          %form#loginform.form-horizontal{role: "form"}
            .input-group{style: "margin-bottom: 25px"}
              %span.input-group-addon
                %i.glyphicon.glyphicon-user
              = f.input :email, :required => false, label: false, :autofocus => true, placeholder: 'username or email', input_html: { class: 'form-control' }
            .input-group{style: "margin-bottom: 25px"}
              %span.input-group-addon
                %i.glyphicon.glyphicon-lock
              = f.input :password, label: false, :required => false
            -#.input-group
              .checkbox
                %label#login-remember
                  = f.input :remember_me, class: "input", type: "checkbox", :as => :boolean if devise_mapping.rememberable?
            .form-group{style: "margin-top:10px"}
              .form-actions.col-sm-12.controls
                = f.button :submit, "Login", id: "btn", class: "btn btn-success"