我有2个型号:
视频:
class Video < ActiveRecord::Base
belongs_to :user
has_many :thumbnails
attr_accessor :search, :saveable
accepts_nested_attributes_for :thumbnails, :allow_destroy => true
en
Run Code Online (Sandbox Code Playgroud)
d
缩略图:
class Thumbnail < ActiveRecord::Base
belongs_to :video
end
Run Code Online (Sandbox Code Playgroud)
我正在使用YouTubeG gem来搜索视频.
搜索返回的每个视频在视图中都有一个表单:
<% form_for :video, :url => videos_path, :html => { :class => :form } do |f| -%>
<%= f.hidden_field :url, :value => video.unique_id %>
<%= f.hidden_field :name, :value => video.title %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<% if video.thumbnails.present? %>
<% f.fields_for :thumbnails, video do |t| %>
<% …Run Code Online (Sandbox Code Playgroud) 例如:逗号分隔在单个文本字段中:mail1 @ domain.com,mail2 @ someotherdomain,...