0

每当我尝试写一个词来搜索它时,我什么也得不到,就好像 Seach 的按钮被禁用了一样。我已经索引了我的博文。

this is for search
%h1 My Blog

= form_tag blog_posts_path, method: :get do 
  %p    
= text_field_tag :query, params[:query]
= submit_tag "Search", name: nil
- @blog_posts.each do |blog_post|
  %p
    %b= link_to blog_post.title, blog_post

  %p= blog_post.content

  %p{style: "float: right;"}
    = link_to "Delete", blog_post, method: :delete, confirm: "Are you sure you want to delete this post?"
    %hr{style: "clear: both;"}

%br

= link_to 'New Post', new_blog_post_path

这个索引 marina@ubuntu:~/project$ rake db:setup 为 BlogPost 生成的索引

4

1 回答 1

0

尝试将text_field_tag和嵌套在submit_tagform_tag,在您的代码中,这些是兄弟节点。

%p
  = form_tag blog_posts_path, method: :get do   
    = text_field_tag :query, params[:query]
    = submit_tag "Search", name: nil
于 2012-04-13T00:33:25.587 回答