i have a has_many :through r'ship in my application. my tables are -
users, apps(short form for applications), categorizations. i'm trying to
create a user in new.rhtml where all apps are also shown in checkboxes
for selection. on submit, user gets created but the join table i.e.
categorizations table doesn't get updated. where am i going wrong?
doesn't the join table gets updated automatically? or do i've to update
it manually? if yes, how? Any help will be greatly appreciated. thanks
I beleive that you need to create the categorizations yourself
something like (this is untested):
class UsersController < ApplicationController
@user = User.new
@apps = App.find(:all)
@user = User.new(params[:user])
params[:user][:app_ids].each do | app_id|
@user.categorizations << Category.new(:app_id => app_id)
redirect_to(:action => "new")
flash[:notice] = "Thanks for signing up!"
render :action => 'new'