0
我有模式叫Product
,它有以下几列:模型有两种不同的形式是安全的吗?
create_table :products do |t|
t.decimal :price
t.string :name
t.integer :offline_store_id
t.integer :online_store_id
t.date :product_date
end
现在我做了两个不同的表格可以看到有关联:
# using find_or_create_by
webstore = online_store_id
store = offline_store_id
<%= form_for @product do |f| %>
<%= f.text_field :price %>
<%= f.text_field :name %>
<%= f.date_select :product_date
<%= f.text_field :webstore %>
<% end %>
另一种形式是,它只是切换相同代替:webstore
与:store
。原因是为在线产品制作一个表格,另一个用于离线。我担心的是,如果该字段仍然可以填写或不填写,即使其中没有任何一种可用。产品不能同时属于在线和离线商店。
这是一件好事吗?即使我没有可用的字段,该字段是否真的消失了,或者黑客仍然可以填写它?
谢谢,太感激的额外信息。我会尝试使用它。 – LearningRoR