我有两个存储内容的表(2 个单独的模型:微帖子和线程)
它们非常相似,除了名字
create_table "microposts", :force => true do |t|
t.text "content"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "review", :default => false
end
create_table "threads", :force => true do |t|
t.text "content"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
这是我的看法
<%= form_for @micropost, :html => {:multipart => true} do |f| %>
<%= render 'shared/error_messages', object: @micropost %>
<div class="field">
<%= f.text_area :content, :cols => 5, :rows => 5, :placeholder => "This field is required" %>
</div>
<label for="a"><%= label_tag(:micropost_review, "Does this need review?") %><%= f.check_box :review %></label></div>
<br><br>
<%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>
我想要做的是,而不是更新评论属性的复选框(label_tag),我想将 form_for 更改为线程。如果在提交之前选中了复选框,我希望它填充线程表,而不是填充 microposts 表。更新上面的视图以执行此操作的最佳方法是什么?谢谢