I have a photographers app that requires giving access to galleries for
users. in one part, I want to be able to define gallery access for a
user seperate from updating any of the user info. I have this function:
@user = User.find(params[:id])
@user.galleries = Gallery.find(params[:gallery_ids]) if
flash[:notice] = ‘Account was successfully updated.’
redirect_to :action => ‘list’
@galleries = Gallery.find(:all)
render :action => ‘manage_access’
The function works and updates the correct fields in the galleries_users
table, but the page errors out on validation errors on @user. I’m
hoping to make a function that only reaches to update @user.galleries
and nothing in the user table.
How do I do it? I’ve tried update_attributes(params[:user][:galleries])
and a few similar things, but really I’m just hacking and would like to
know the proper way.