【发布时间】:2011-10-06 12:13:37
【问题描述】:
我有一个 Rails 项目,它有一个简单的映射关系,如下所示:
模型类别
has_many :stories
模特故事
belongs_to category
在我的故事控制器中,我有
def new
@story = Story.new
@categories = Category.all
end
然后在我的 new.html.erb 我有
<%= form_for @story do |f| %>
<%= f.text_field, :title %>
<%= collection_select(:story, :category_id, @categories, :id, :name)%>
<% end %>
我想用<%= f.text_field%>(文本字段)替换<%= collection_select %>(选择框)并使用jquery toxeninput javascript插件填充数据,我不知道该怎么做。
【问题讨论】:
标签: jquery ruby-on-rails ruby-on-rails-3 json jquery-tokeninput