Displaying 4 results from an estimated 4 matches for "user_group_id".
2006 Apr 20
5
Using Migrations to convert join table to join model
Greetings,
I''m trying to convert a HABTM w/attributes join table in my database
into a join model table in order to utilize the new has_many :through
functionality introduced in Rails 1.1. Here''s the current table
definition:
licenses_user_groups: license_id, user_group_id, usage_notes
Perhaps it was a mistake, but I made (license_id, user_group_id) the
primary key.
Now, after playing with has_many :through, I have discovered that, among
other modifications, I really need to add an id column to the table and
make it the primary key. However, I cannot figure out...
2007 Dec 28
1
validation of acts_as_list in the model of the base class?
Lets say I have 3 models, user, user_group and user_group_nodes. A
normal user has one user_group_id as a foreign key and a special user
has multiple user_groups which are defined in the user_group_nodes.
The user_group_nodes is a "acts_as_list" for user and contains a list
of group_ids.
When I build a form to get user input and I want to save it, is there
a way to validate the presence...
2010 Jun 11
0
nested form & habtm
...model (user.rb)
class User < ActiveRecord::Base
has_and_belongs_to_many :user_groups
accepts_nested_attributes_for :user_groups
end
UserGroups model (user_groups.rb)
class UserGroup < ActiveRecord::Base
has_and_belongs_to_many :users
end
users_controller.rb
def new
@user = User.new(:user_group_ids => params[:group])
end
in the new user view, i have access to the User.user_groups object,
however when i submit the form, not only does it not save into my join
table (user_groups_users), but the object is no longer there. all the
other objects & attributes of my User object are persiste...
2007 Sep 20
1
Relationship Proxies?
...9;'aaron''
=> #<User:0xb7109cdc
@attributes={"salt"=>"7e3041ebc2fc05a40c60028e2c4901a81035d3cd",
"updated_at"=>nil, "contact_info_id"=>nil,
"crypted_password"=>"00742970dc9e6319f8019fd54864d3ea740f04b1",
"user_group_id"=>"10", "remember_token_expires_at"=>nil, "id"=>"2",
"disabled"=>"0", "remember_token"=>nil, "locale"=>nil,
"login"=>"aaron", "created_at"=>"2007-09-18 19:...