将simple_form标记转换为bootstrap

时间:2015-05-12 01:56:40

标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4 haml

我有这个简单的postgres搜索表单,我从railscasts获得:

    %h2
        Search textbook title or ISBN
    = simple_form_for books_path, method: :get do
        = search_field_tag :query, params[:query]
        = submit_tag "Search", name: nil

和这个引导搜索表单(以haml为单位):

.featurette
.featurette-inner.text-center
    %form.search{:role => "form"}
        %h3.no-margin-top.h1 Search Me.
        .input-group.input-group-lg
            %input.form-control{:placeholder => "search", :type => "search"}
                %span.input-group-btn
                    %button.btn.btn-primary{:type => "submit"} Search

我希望“search_field_tag”成为“input.form-control”,将“submit_tag”变成“button.btn.btn-primary”。

需要你的帮助才能将这两者结合起来,因为我无法使搜索和提交按钮起作用。刚刚开始使用2周的导轨。任何支持都非常感谢。

谢谢!

1 个答案:

答案 0 :(得分:0)

@Jon我仍然不理解我正在做的大部分事情并使用f.input而不是= search_field_tag只是给了我一个错误。我能够让它工作。以下是我使用的内容:

.featurette
.featurette-inner.text-center
    %form.search{:role => "form"}
        %h3.no-margin-top.h1 Search Me.
        = simple_form_for books_path, method: :get do   
            .input-group.input-group-lg 
                = search_field_tag :query, params[:query], class: "form-control"
                %span.input-group-btn
                    = submit_tag "Search", name: nil, class: "btn btn-success"