我有一个关于将值存储到整数变量的问题。是否可以将不同的ID存储到同一个变量中? 这是我的问题,我想用一个collection_select来保存很多ID。 我的代码实际上是工作的一个变量,像这样:将值存储到整数变量
我的代码:
用户模式:
has_many :pins
scope :artist, -> { where(artist: true) }
针型号:
belongs_to :user
引脚控制:
def new
@pin = Pin.new
@users = User.all.artist
end
def create
@pin = current_user.pins.build(pin_params)
if @pin.save
redirect_to @pin, notice: "successfully created!"
else
render 'new'
end
end
引脚/新(视图):
<div class="form-group">
<%= f.collection_select(:pin_maker, @users, :id, :pseudo) %>
</div>
我想类似的东西为我的新观点:
<div class="form-group">
<%= f.collection_select(:pin_maker, @users, :id, :pseudo, { }, {:multiple => true}) %>
</div>
但变量不是在我的SQL表保存。 所以我的问题是:这是可能存储在同一个变量(pin_maker),这是一个整数多个ID?或者我应该为此创建一个新表格?
'这是可以存储许多ID在同一个变量(: pin_maker)这是一个整数?'=> no –