【发布时间】:2016-03-25 22:04:12
【问题描述】:
我正在尝试让“#”之前的文本成为我的 Rails 4.0.0 应用程序中的主题标签。我正在尝试使用红宝石宝石simple_hashtag
为了这个目的。我在post_controller.rb 中遇到的错误是:undefined method 'hashtags' for #<ActiveRecord::Relation::ActiveRecord_Relation_Post...>
这是发生此错误的操作:
def index
@posts=Post.sorted
@posts.hashtags.each do |hashtag|
link_to hashtag.name, path_to_hashtag(hashtag.name)
end
end
这是 Post 的模型,即post.rb
class Post < ActiveRecord::Base
include SimpleHashtag::Hashtaggable
hashtaggable_attribute :text
end
有人可以帮我运行这个 gem 吗?提前致谢。
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 rubygems hashtag