Ruby on rails 3 使用“始终显示空数组”标记的_(用作标记)

Ruby on rails 3 使用“始终显示空数组”标记的_(用作标记),ruby-on-rails-3,acts-as-taggable-on,Ruby On Rails 3,Acts As Taggable On,我在(3.0.1)上使用acts作为标记,并在控制台上尝试了一些代码: irb(main):005:0* Noticia.last.tags => [#<ActsAsTaggableOn::Tag id: 9159, name: "oil">] irb(main):006:0> Noticia.tagged_with("oil") => [] 我不知道问题出在哪里,在doc上充当标记的角色时,我只是运行“Model.taged_with(“my_tag”)”。我按

我在(3.0.1)上使用acts作为标记,并在控制台上尝试了一些代码:

irb(main):005:0* Noticia.last.tags
=> [#<ActsAsTaggableOn::Tag id: 9159, name: "oil">]
irb(main):006:0> Noticia.tagged_with("oil")
=> []
我不知道问题出在哪里,在doc上充当标记的角色时,我只是运行“Model.taged_with(“my_tag”)”。我按照这些步骤在上配置作为标记的行为,我遇到了类似的问题:

> post = Post.create(body: "Hello world")
=> <Post id: 9, title: nil, body: "Hello world", author_id: nil, author_type: nil, created_at: "2015-10-07 08:53:32", updated_at: "2015-10-07 08:53:32">
> post.tag_list.add('hello', 'world')
=> ["hello", "world"] 
> Post.tagged_with('hello')
=> <ActiveRecord::Relation []>
> Post.tagged_with('world')
=> <ActiveRecord::Relation []>
>post=post.create(正文:“Hello world”)
=> 
>post.tag_list.add('hello','world'))
=>[“你好”,“世界”]
>Post.taged_为('hello')
=> 
>Post.用('world'标记_)
=> 
我的错误是,在将标签添加到帖子的标签列表后,我只是忘记了保存帖子:)

>post.save
=>正确
>Post.taged_为('hello')
=>  
> post = Post.create(body: "Hello world")
=> <Post id: 9, title: nil, body: "Hello world", author_id: nil, author_type: nil, created_at: "2015-10-07 08:53:32", updated_at: "2015-10-07 08:53:32">
> post.tag_list.add('hello', 'world')
=> ["hello", "world"] 
> Post.tagged_with('hello')
=> <ActiveRecord::Relation []>
> Post.tagged_with('world')
=> <ActiveRecord::Relation []>
> post.save
=> true
> Post.tagged_with('hello')
=> <ActiveRecord::Relation [#<Post id: 9, title: nil, body: "Hello world", author_id: nil, author_type: nil, created_at: "2015-10-07 08:53:32", updated_at: "2015-10-07 08:53:32">]>