I have a legacy DB without access to change the user or group table
(must use StoredProcedures to edit those). But I do have access to the
usergroup join so I thought the joins would be pretty much like my other
rails apps where I do HABTM checkboxes. I''ve created a page that just
shows habtm checkboxes for the join and the updates are occuring for the
join but I''m getting Access errors on the user table (which I should) .
how do I limit what RAILS wants to update to just the join table. I
thought this (http://wiki.rubyonrails.org/rails/pages/CheckboxHABTM)
would do it based on the last comment.
here''s my relevant parts
def joinupdate
@user = user.find(params[:user][:CodeMgmtUserId])
if !params[:user]
@user.groups.clear
else
if
@user.update_attribute(:group_ids,@params[''user''][''CodeMgmtgroupId''])
flash[''notice''] = "Update Successful"
else
render_action ''edit''
end
end
end
joinupdate.rhtml
<h1>Editing User/Group association for <%= @user.Name %></H1>
<% group.find(:all, :order => "name ASC").each do |mygroup|
%><BR>
<%= check_box_tag ''user[CodeMgmtGroupId][]'', mygroup.id,
@user.groups.include?(mygroup) %>
<%= mygroup.Name %>
<% end %>
thanks
-zaq
--
Posted via http://www.ruby-forum.com/.
I still can''t get this to work . here''s the SQL that''s being executed. the first tow are correct, I''ve selected two checkboxes, pressed submit SQL (0.037381) INSERT INTO tbl_CodeMgmt_groupuser ([CodeMgmtgroupId], [CodeMgmtuserId]) VALUES (1, 8) SQL (0.021232) INSERT INTO tbl_CodeMgmt_groupuser ([CodeMgmtgroupId], [CodeMgmtuserId]) VALUES (2, 8) fine, but then it does (or rather errors while..) User Update (0.000000) DBI::DatabaseError: 42000 (229) [Microsoft][ODBC SQL Server Driver][SQL Server]UPDATE permission denied on object ''tbl_CodeMgmt_user'', database ''mytestDB'', owner ''dbo''.: UPDATE tbl_CodeMgmt_user SET [desk] = '''', [floor] = 1, [title] = '''', [Name] = ''z2'' WHERE Id = 8 isn''t update_attribute supposed to update only what I pass as an argument? in this case "group_ids " user.update_attribute(:group_ids,@params[''user''][''CodeMgmtgroupId'']) help -- Posted via http://www.ruby-forum.com/.