I have a question about storing a value into a integer variable. Is it possible to store different id into the same variable ? This is my problem, I would like to use a collection_select to save many id's. My code is actually working for one variable, like this :
My code :
User model :
has_many :pins
scope :artist, -> { where(artist: true) }
Pin model :
belongs_to :user
Pin controller:
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
Pin/new(views):
<div class="form-group">
<%= f.collection_select(:pin_maker, @users, :id, :pseudo) %>
</div>
I would like something like that for my new views :
<div class="form-group">
<%= f.collection_select(:pin_maker, @users, :id, :pseudo, { }, {:multiple => true}) %>
</div>
But the variables are not saving in my sql table. So my question is : That's possible to store many id in the same variable (:pin_maker) which is an integer ? Or should I create a new table for that ?
That's possible to store many id in the same variable (:pin_maker) which is an integer ?=> no