因此,我尝试使用 JBuilder 返回一些相当标准的 json,其中一个字段是 Redcarpet 将一些 Markdown 解析为 HTML。
json.categories @all_categories do |category|
json.extract! category, :name
json.black_icon_url category.black_icon.url
json.white_icon_url category.white_icon.url
json.events category.events do |event|
json.extract! event, :name, :short_description
json.descripton event, @markdown.render(event.description) # LOOK HERE!
json.image_url event.image.url
json.contacts [event.contact1, event.contact2] do |contact|
json.extract! contact, :name, :phone, :facebook_username if contact
end
end
end
问题是这段相当简单的代码会抛出一个NoMethodError
.
Showing /../app/views/events/index.json.jbuilder where line #8 raised:
undefined method `<p>Speed is what defines us.</p>...
我对此感到有些困惑......似乎这个字符串以某种方式变成了方法调用?