Search Results

Search found 1724 results on 69 pages for 'belongs on superuser'.

Page 6/69 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • nested form & habtm

    - by brewster
    so i am trying to save to a join table in a habtm relationship, but i am having problems. from my view, i pass in a group id with: = link_to "Create New User", new_user_url(:group => 1) User 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 persistent except for the user group. i just started learning rails, so maybe i am missing something conceptually here, but i have been really struggling with this.

    Read the article

  • declarative authorization and has_and_belongs_to_many

    - by Michael Balsiger
    Hi, I have a little problem with declarative-authorization. I have a User and Role Model with a has_and_belongs_to_many association. I've created a Role named :moderator in my authorization_rules.rb Is it possible that a User with the Role Moderator only gets the Users that have the Moderator Role assigned to it?? -- User.with_permissions_to(:index) I thought it would be possible like that: role :moderator do has_permission_on :users, :to => :index do if_attribute :roles => contains { ????? } end end I also created a named_scope in my User Model because I thought it would help... class User has_and_belongs_to_many :roles named_scope :by_role, lambda { |role| { :include => :roles, :conditions => {"roles.name" => role} } } end Does anyone knows if it's possible to do this with declarative_authorization? Thanks for your help!

    Read the article

  • Simulating a belongs_to_many in rails

    - by DavidP6
    I have a situation where in theory I would need to use a belongs_to_many relationship. I have an Example model and a Sentence model. Each example object has one sentence but these sentences are not necessarily unique. So, for example, I could have two example models that each have one sentence that is the same sentence. I'm not sure how to go about doing this in rails. I tried using has_and_belongs_to_many, but ran into problems. It seems that I only need the belongs_to :many part of that relationship. Ideally it would look something like this, but I know there is no belongs_to :many. Example has_one :sentence end Sentence belongs_to_many :examples end

    Read the article

  • CakePhp: model recursive associations and find

    - by Petecocoon
    Hello to everybody! I've some trouble with a find() on a model on CakePhp. I have three model relationed in this way: Project(some_fields, item_id) ------belongsTo----- Item(some_fields, item_id) ------belongsTo----- User(some_fields campi, nickname) I need to do a find() and retrieve all fields from project, a field from Item and the nickname field from User. This is my code: $this->set('projects', $this->Project->find('all', array('recursive' => 2))); but my output doesn't contains the user object. I've tried with Containable behaviour but the output is the same. What is broken? Many many Thanks Peter

    Read the article

  • Undefined method for a belongs_to association

    - by marimaf
    My code: class User < ActiveRecord::Base belongs_to :university end class University < ActiveRecord::Base has_many :users, dependent: :destroy end and my model User has a university_id attribute. If I do University.find(1).users I get the list of users, but if I do User.find(1).university (and I checked that university_id is not nil here) I get: NoMethodError: undefined method `university' for from /home/mari/.rvm/gems/ruby-1.9.2-p290/gems/activemodel-3.0.10/lib/active_model/attribute_methods.rb :392:in `method_missing' from /home/mari/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.10/lib/active_record/attribute_methods. rb:46:in `method_missing' from (irb):14 from /home/mari/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in sta rt' from /home/mari/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in star t' from /home/mari/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.10/lib/rails/commands.rb:23:in <top (requi red)>' from script/rails:6:inrequire' from script/rails:6:in `' What am I doing wrong? I have another models and they are working just fine. Any suggestions? Thanks in advance

    Read the article

  • Two Different Types of Associatons on the Same Two Tables in Rails

    - by tmo256
    I have two models, users and themes, that I'm currently joining in a HABTM association in a themes_users table. Basically, after a user creates a new theme, it becomes available to other users to select for their own use. However, only the original creator of the theme should have the ability to edit it. So, I need to have some other kind of association to handle that relationship, something like an created_by_id field in the theme. In this way, the user model acts as two different roles: they can be an implementer of a theme AND/OR the owner of the theme. The implementer relationship is handled by the themes_users join table; the question is: What is the right way to handle this secondary association? Do I need to make users polymorphic and then make the created_by_id reference an "owner"? Or is there something easier? Thanks so much for your help!

    Read the article

  • Double join with habtm in ActiveRecord

    - by Daniel Huckstep
    I have a weird situation involving the need of a double inner join. I have tried the query I need, I just don't know how to make rails do it. The Data Account (has_many :sites) Site (habtm :users, belongs_to :account) User (habtm :sites) Ignore that they are habtm or whatever, I can make them habtm or has_many :through. I want to be able to do @user.accounts or @account.users Then of course I should be able to do @user.accounts < @some_other_account And then have @user.sites include all the sites from @some_other_account. I've fiddled with habtm and has_many :through but can't get it to do what I want. Basically I need to end up with a query like this (copied from phpmyadmin. Tested and works): SELECT accounts.* FROM accounts INNER JOIN sites ON sites.account_id = accounts.id INNER JOIN user_sites ON sites.id = user_sites.site_id WHERE user_sites.user_id = 2 Can I do this? Is it even a good idea to have this double join? I am assuming it would work better if users had the association with accounts to begin with, and then worry about getting @user.sites instead, but it works better for many other things if it is kept the way it is (users <- sites).

    Read the article

  • HABTM checking for match of latest 3

    - by user333614
    Here's an interesting one for you folks... I have a HABTM (has_and_belongs_to_many) relationship between "Dogs" and "Trips". My goal is to find two result sets: 1) Dogs that have been on at least 1 of the last 3 trips and call that @dogs_current 2) Dogs that have NOT been on any of the last 3 trips and call that @dogs_old I found that I can find what the last 3 trips are by doing this in the Trip model: named_scope :last3, :order => 'date DESC', :limit => 3 But not sure how to use that list get 1 and 2. This hack works, but it seems ugly. There must be a better way! :) @dogs_current = [] @dogs_old = [] @dogs.each do |dog| if (Trip.last3 - dog.trips).size < 3 then @dogs_current << dog else @dogs_old << dog end end Any ideas? Thanks! -Cam

    Read the article

  • Rails - HABTM Relationship -- How Can I Find A Record Based On An Attribute Of The Associated Model

    - by ChrisWesAllen
    I have setup this HABTM relationship in the past and its worked before....Now it isnt and I'm at my wits end trying to figure out whats wrong. I've looking through the rails guides all day and cant seem to figure out what I'm doing wrong, so help would really be appreciated. I have 2 models connected through a join model and I'm trying to find records based an attribute of the associated model. Event.rb has_and_belongs_to_many :interests Interest.rb has_and_belongs_to_many :events and a join table migration that was created like create_table 'events_interests', :id => false do |t| t.column :event_id, :integer t.column :interest_id, :integer end I tried @events = Event.all(:include => :interest, :conditions => [" interest.id = ?", 4 ] ) But got the error "Association named 'interest' was not found; perhaps you misspelled it?"... which I didnt of course I tried @events = Event.interests.find(:all, :conditions => [" interest.id = ?", 4 ] ) but got the error "undefined method `interests' for #Class:0x4383348" How can I find the Events that have an interest id of 4....I'm definitely going bald from this lol

    Read the article

  • How to set up two models having a has_many association with each other

    - by daz13
    I'm looking for a suggestion on how to set up two models, Teacher and Subject. A Teacher can have many Subjects, and a Subject can have many Teachers. Another thing to consider in the relationship between the two models is that a Teacher can create a Subject and add other Teachers to the Subject. I think I'm solid on the basics of the set up for each model: for teacher.rb: has_many :subjects for subject.rb: has_many :teachers and the teachers table should have a subject_id column and the subject table should have a teacher_id column. What I'm not sure about is how to set up the views (and corresponding controller methods) to allow the addition of a Teacher to a Subject. Any suggestions (or links to examples) are greatly appreciated. I haven't been able to find anything on this exact case.

    Read the article

  • acts_as_list with has_and_belongs_to_many relationship

    - by mculp
    I've found an old plugin called acts_as_habtm_list - but it's for Rails 1.0.0. Is this functionality built in acts_as_list now? I can't seem to find any information on it. Basically, I have an artists_events table - no model. The relationship is handled through those two models specifying :has_and_belongs_to_many How can I specify order in this situation?

    Read the article

  • How to run a script in Ubuntu via SSH as superuser?

    - by Irinotecan
    So I have a script that needs to be executed remotely as root. This isn't a problem with most Linux distros since they have a root account. But since Ubuntu does not, executing anything as root requires a 2-step process of entering the account password twice - once to log in and once for sudo. The SSH process to launch the script is automated, so it cannot pause for user input for the second password request. Does anyone know, short of hacking Ubuntu to re-enable root (not an option), if unattended SSH script execution with superuser privilege on the target machine is possible? Also, having no experience with Debian, does Debian behave this way too?

    Read the article

  • How do I determine that an instance of org.apache.poi.hwpf.model.ListData belongs to a numbered lis

    - by leighgordy
    Is there a way to determine if an instance of a org.apache.poi.hwpf.model.ListData belongs to a numbered list or bulleted list? I am using Apache Poi's org.apache.poi.hwpf.HWPFDocument class to read the contents of a word document in order to generate HTML. I can identify the list items in the document by checking to see that the paragraph I am working with is an instance of org.apache.poi.hwpf.model.ListData. I can not find a way to determine if ListData belongs to a bulleted list or a numbered list.

    Read the article

  • OS X superuser folders automatically created. Perusers launchd process appears to kill 501

    - by Ric Pen
    New Apple laptop OSX 10.8.2. I have used OS X but many years previously, and am not familiar with subtleties or changes in com.apple.launchd.peruser.x... I have previously (and in retrospect, foolishly) made changes to these rapidly spawned new peruser accounts (my initial reaction was that if ipfw was disabled, then I might well be under hacker attack, which I have dealt with, years ago), but I believe I was wrong, and the results of my efforts at preserving the system's integrity have in fact been destructive, overreactive, and have resulted in much work to restore. My understanding from other posts is that superuser protocols have changed quite dramatically since I bought the first developer version of OS X many years ago. Haven't developed on Apple much since then, w/ exception of WebObjects (IMO, much underrated at that time, and was more user friendly than ASP (prior to .NET, I vaguely recall). Creation of apparently nasty peruser folders appear to confound 501 process, which logs inability to find firewall (ipfw). Can someone help me with this? I am concerned that either the system is improperly configured, an application was improperly installed (although there is little here beyond Apple's SDK, which I find quite accommodating and intuitive). Still, I am a novice, only sporadically develop at this time, and would really just like to see this system running happily. Please offer assistance, in the form of potential info sources, or if you have had a similar experience, then perhaps scripts to suss out this issue. I do not wish to damage the system, but Apple's Developer connection and discussion threads do not appear to have dealt with this particular issue recently... Although I may well have missed something you have not - please apprise. Any assistance on this issue is very much appreciated - by an old guy, who wants to do some things which were fun about 20 years ago.

    Read the article

  • LaTeX: How to find package(s) that a command belongs to?

    - by Ashwin
    It is a simple question to which I am not able to find the answer: Given a LaTeX command, how do I find out what package(s) it belongs to or comes from? For example, given the \qquad horizontal spacing command, what package does it come from? Especially troublesome since it works without including any package!

    Read the article

  • Is there built-in method to tell if specific URL belongs to this SPWeb or other SPWeb?

    - by Janis Veinbergs
    Hello. I have a list of urls (content type usage url's). Now, content types are deployed across web's. I need to loop those content types and do some actions in each list, but opening new SPWeb instance every loop is too resource intensive. Is there built-in method to tell me if this URL belongs to certain SPWeb object? Example: SPWeb's may be http://server/web1 http://server/web2 http://server/web2/subweb1 http://server/web2/subweb2 With content type usage links like: /web2/Pages /web2/Lists/Tasks /web2/Lists/Documents /web2/subweb1/Lists/Tasks ... As you can see, for first 3 usages i don't need to open up new SPWeb

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >