similar to: Check if user is in right group

Displaying 20 results from an estimated 100 matches similar to: "Check if user is in right group"

2006 Jun 08
3
has_many :through updates on delete.
I have a model that looks like this: class Actor < ActiveRecord::Base has_many :member_groups, :foreign_key => ''member_id'', :class_name => ''GroupMember'' has_many :groups, :through => :member_groups, :source => :group end class Group < Actor has_many :group_members, :foreign_key => ''group_id'',:dependent =>
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
2006 Feb 12
6
habtm doesn''t save old IDs
I''m sure I''m not getting something. I have Users, and I have Groups. Each User has_and_belongs_to_many :groups and each Group has_and_belongs_to_many :users. When I add a user, I want to apply a bunch of groups (like tags) to the user (manually, without acts_as_taggable). Here''s User#create: @user = User.new(params[:user]) @user.groups =
2006 Apr 20
8
Whats the best way to do this?
I have an archive that can have 0 or more extra files associated with it. I would like to be able to edit the associated files info on the same page as the archive info. Listing the extra files info to the edit form is simple enough, but How do I form the text input fields for easy (or automatic) pick-up in the update? Or am I barking up the wrong tree here? -- Posted via
2006 Feb 21
6
Select articles from group with id ''1'' and id ''2''
I have to tables: "articles" and "groups". Between I have article_groups as a jointable. Now I want to select every article who is a member of group with id ''1'' and id ''2''. Whats best way to get that? Extract from schemas: CREATE TABLE articles ( id int auto_increment, ingress text NOT NULL, story_text longtext, constraint fk_items_users
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/.
2005 Oct 15
1
Partials and controllers
Newbie question: From a _form.rhtml file I have: <%= render(:partial => ''item'', :collection => @items) %> In _item.rhtml I have: <% @tullt = h(item.body) %> <%= @itemdb = Group.find(:all, :conditions => "id = ''#{@tullt}''").map {|u| [u.name] } %> <%= @tullt % I think it would be better to
2006 Apr 08
5
rails.el on Ubuntu
Anybody who have a working .emacs (++) for Ubuntu (or Debian) with the newest emacs-rails (v.0.3). I have especially trouble with getting HTML Mode Snippets to work. - Henrik
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,
2006 Jan 03
0
has_and_belongs_to_many include problem
hey, i have users who are in groups, and i have a search form, where i can search on group, user lastname, and user firstname. All this is also with pagination. 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
2006 Jun 09
0
Sortable list with non ajax submission
I am trying to create a sortable list that is submitted not with an AJAX call but by a standard form submit button. Right now I have def reorder_group_members @group = Group.find(params[:id]) @group.group_members.each do |member| member.position = params[:memberlist].index(member.id.to_s) + 1 #I get a nil error for this line. It would seem that params[:memberlist] is not
2006 Apr 08
76
MIT vs GPL vs LGPL for open source project
I intend to release a project I wrote with Rails. What is the right licensing scheme for a web application (content managing system) which could grow with plugins and add-ons ? Personally, I would prefer the GPL but does that mean any add-on to the CMS (like task management) will have to be GPL ? If some people contribute to the code could it still be double-licenced so that the people who
2012 Jun 18
0
Creating an object with a nested has_many :through relationship
I have 3 models that define members, groups and the subscriptions: Member, Group, and GroupMember. class Member < ActiveRecord::Base > has_many :group_subscriptions, class_name: "GroupMember" > has_many :groups, through: :group_subscriptions > attr_accessible :email, :password > end > class Group < ActiveRecord::Base > has_many :member_subscriptions,
2006 Sep 05
0
rake craziness with Migrate as a dependency
Hi everyone, For one of our projects we have a need to deploy and maintain a demo. As a result I''ve attempted to setup a set of rake tasks for the job. My goal is have one rake task called "deploy_demo" which purges the database, migrates to the current schema, and loads the db from a set of fixture files in a specified location. I''ve written two new tasks the perform
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
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
2006 Jul 02
2
searchbar help!
Hi all, i am after hours unfold of trying to implement a searchbar in a table with a habtam relashinship, but alas ! with no success... i was hoping some kind gentle mind can help me through these diffucult times; i have now reached the point where out 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
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