search for: groups_users

Displaying 13 results from an estimated 13 matches for "groups_users".

2005 Dec 15
3
How to delete a record
hey, i my database i have users and groups, each user can get in different groups my db structure: table groups: id, name, basegroup, firm_id table users: id, firstname, lastname, email table groups_users: group_id, user_id my relation is a many to many: class Group < ActiveRecord::Base has_and_belongs_to_many :users end class User < ActiveRecord::Base has_and_belongs_to_many :groups end i want this http://wiki.script.aculo.us/scriptaculous/show/SortableListsDemo with ajax, first col...
2006 Feb 12
6
habtm doesn''t save old IDs
...s = params[:user][:group_names].split(/\s+/).collect do |group| Group.find(:first, :conditions => ["name = ?", group]) || Group.new({:name => group}) end @user.save Groups that have not yet been created are created and their associations to the user are saved in groups_users. Groups that already exist, however, are *not* added to groups_users. The further oddity is that User#groups=() does add previously existing Groups, *if* I call it on a User object that has already been added to the database. Here''s an entry from the logs: before save, groups=[#<...
2006 Jan 03
0
has_and_belongs_to_many include problem
...these are my models class User < ActiveRecord::Base has_and_belongs_to_many :groups end class Group < ActiveRecord::Base has_and_belongs_to_many :users end in my controller i do this THIS works (but in need pagination) @users2 = User.find_by_sql("select users.* from groups, users, groups_users where groups.id = " + @group_id.to_s + " and groups_users.group_id = groups.id and groups_users.user_id = users.id and users.last_name like ''%" + @last_name.to_s + "%'' order by users.last_name ASC, users.first_name ASC") i get an error on this (can anyone...
2006 Jan 28
6
Check if user is in right group
What is the best way of checking this? I have 3 tables: groups users group_members class GroupMember < ActiveRecord::Base belongs_to :group belongs_to :user validates_uniqueness_of :user_id, :scope => "group_id" Then I want a method here that checks if a given user is a member of a given group. What is the right way of doing that? def
2006 Jul 02
18
JOIN conditions
Hi, how can I get Rails to generate SQL queries with conditions in the JOIN clause? What I would want is: SELECT * FROM people p LEFT OUTER JOIN jobs j (p.job_id = j.id AND j.salary > 9999999) I tried People.find(:all, :include => ''jobs'', :conditions => ''jobs.salary > 9999999'') but that generates SELECT * FROM people p LEFT OUTER
2006 Apr 20
12
memcache, sessions, fragments, oh my!
Hi all - I am trying to get rails to use memcache for sessions and fragment caching. I''d also like to use the same connection for general caching of this and that. I''m following the instructions here: http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionStore and hitting a brick wall. I''m using the new memcache-client since from what I''ve read
2006 May 11
7
current user''s id?
I''m new to rails and have a question that seems simple but that I cannot resolve. Is there a way to find the id of the currently logged in user? Thanks, JP -- Posted via http://www.ruby-forum.com/.
2006 Sep 05
0
rake craziness with Migrate as a dependency
...- add_index("groups_roles", ["group_id", "role_id"], {:name=>"groups_roles_all_index", :unique=>true}) -> 0.2200s -- add_index("groups_roles", ["role_id"], {:name=>"role_id"}) -> 0.2200s -- create_table("groups_users", {:force=>true, :id=>false}) -> 0.1010s -- add_index("groups_users", ["group_id", "user_id"], {:name=>"groups_users_all_index", :unique=>true}) -> 0.2100s -- add_index("groups_users", ["user_id"], {:name=>&...
2006 Jun 29
1
search action/ in different groups
Hi all, thanks in advance for those who''ll take the time to help out... i have a list of users who are connected with a habtam relashinship to a set of groups (joint table of groups_users) and now am trying to implement a search operation that will go through all of the records of the users and output user results according to what group was chosen at the searchbar, and the text input(of the searchbar) basicly, it would be something in the vicinity of (( @groups = Group.find_al...
2005 Dec 14
0
how to get these records in has_and_belongs_to_many relation
hey, i my database i have users and groups, each user can get in different groups my db structure: table groups: id, name, basegroup, firm_id table users: id, firstname, lastname, email table groups_users: group_id, users_id my relation is a many to many: class Group < ActiveRecord::Base has_and_belongs_to_many :users end class User < ActiveRecord::Base has_and_belongs_to_many :groups end i want this http://wiki.script.aculo.us/scriptaculous/show/SortableListsDemo with ajax, first co...
2006 Jul 02
2
searchbar help!
...t of sheer annoyance, i cannot see myself getting anywhere nearer to the target, and was hopefully hoping one of you out there could help me out.. so enough with the prologue; here is the story: I have two tables joined with a has_and_belongs_to_many relashinship - - users and groups ( and groups_users, accordingly). in my view index.rhtml i have a list of users that each are associated to a couple of groups (say: user1: email1, username1, otherfields1, + g1 g2 g4 user2: email2, username2, otherfields2, + g1 g2 g4 g5 user3: email3, username3, otherfields3, + g1 g3 g4 etc... my need is to imp...
2006 Jun 29
7
sql question for rails
Hi, i was hoping someone could help me out with a small yet quite time-boggling task...i have a two tables users, groups joined in as a habtam relashinship (has and belongs to many) and i need to select from the mydb (mysql if it matters) users out of the User model, in accordance with TWO groups in one rails opperation to improve performance...basicly, say i have ten groups and ten users,
2007 Nov 24
12
orphan habtm rows
HI, i use models User and Groups connected with many to many association, so i have users table, groups and groups_users. lets say i create one user and one group. next i add a group to user. so now my table groups_users has one entry i.e. group_id | user_id _________|________ 1 | 1 ok, when i delete both my group and user, above entry is not deleted, thus leaving alone without any reason.. its just an...