select_tag 'product[provider_ids][]', collection_options_with_selected
#pseudo
def preview
@product = Product.find params[:id]
@product.attributes = params[:product] #provider_ids saved here
if @product.valid?
render 'confirm;
else
render 'edit'
end
end
build is not appropriate and push has the same functionality as
assigning to provider_ids.
So I have to do this:
def preview
@product = Product.find params[:id]
@product.attributes = params[:product] #no product
@selected_providers = Provider.find_by_ids params[:provider_ids]
#to display provider names in confirm page
#...
end
def update
@product = Product.find params[:id]
@product.attributes = params[:product]
@provider_ids = params[:provider_ids]
if @product.valid?
Product.transaction do
@product.provider_ids = @provider_ids
@product.save
end
else ...
end
There's no way to do this in the typical Rails attribute assignment
fashion?
On Dec 31, 11:08 am, MaggotChild <hsomob1...@yahoo.com> wrote:
> def preview
> @product = Product.find params[:id]
> @product.attributes = params[:product] #no product
I meant that no provider_ids are included in params