similar to: Join Finder Question (ActiveRecord)

Displaying 20 results from an estimated 20000 matches similar to: "Join Finder Question (ActiveRecord)"

2010 Jun 03
2
creating fixtures for has_many :through
I''m stymied at how to create a fixture that establishes a has_many :through relationship. I''ve watched the railscast at: http://media.railscasts.com/videos/081_fixtures_in_rails_2.mov ... but that''s for HABTM relationships. I''ve read: http://www.ruby-forum.com/topic/145676 but that ultimately doesn''t answer any question. So with no further ado:
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi. I have a couple of best practices questions regarding polymorphic associations, naming join tables and user permissions. Currently I have implemented the user authentication model from the rails recipes book. Basically it goes something like this: MODEL CLASSES: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base
2005 Mar 26
2
ActiveRecord help needed
Hello, my name is Magnus and I am a RoR-newbie. I am trying to get the grip of ActiveRecord but I am having trouble to find good examples. I have been looking at this: http://wiki.rubyonrails.com/rails/show/AccessControlListExample Where you can find this Model code: require ''active_record'' class Permission < ActiveRecord::Base has_and_belongs_to_many :roles end
2006 Feb 15
4
problem with saving id''s in a join table
hello, I''am new to ROR and I have a problem. I have to models "rights" and "roles" on a has_and_belongs_to_many relationship, through "roles_rights" table. When I try to add a new role although I put in my form fields for each right, a record is added to table roles but none to roles_rights. I am using Ruby 1.8.4 rails 1.0 mysql 5.0 here is my code:
2007 Aug 10
1
How to spec a model method
Still new to Specs... How do I create a spec to test a model method? Specifically, here is my spec: #testing model describe User do it "should have many user roles" do User.reflect_on_association(:user_roles).should_not be_nil end it "should have many roles though user roles" do User.reflect_on_association(:roles).should_not be_nil end it "should know
2006 Mar 28
1
Master - Detail Form
Hi, I''m new with RoR. I''m trying to do a master-detail CRUD form, using generate scaffold. The problem I''m facing is that I have to keep the parent id through the detail view all the time by hand. Is there any example or way to see how to do it properly? Thanks. Fernando. PS: For further information, I have a Task and the Tasks have Items, so when I want to add an
2005 Oct 11
4
Searching an attribute in a hmabtm relationship
(Nuby to Ruby and Rails...) I''ve implemented security using the login generator in a simple app so that I have a user table, a roles table, and a join between them (roles_users). All works as expected. I now need to check if a user has a specific role, but my approach is off somehow. Here''s what I''ve tried thusfar: user_roles = @session[:user].roles
2006 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would kick the tires on Rails to see if it can speed up development for internal applications. Anyway, I am running into a problem that is just driving me crazy and everything I read on the net doesn''t seem to help. I was hoping someone here might
2005 Dec 14
3
why would an int column in a join table be a String class in model?
i''ve got an issue with integer columns in the database becoming strings in the model and I''m not sure why this is happening. perhaps someone can explain. given the following setup (simplified for example) tables: users ---------- id - int name - varchar(60) roles ---------- id - int name - varchar(60) roles_users (join table) ---------- role_id - int user_id - int
2006 Jun 04
2
activerecord table help please
Hi everyone. I''m trying to figure out how to implement site-wide tagging for my website. I have a rails-based weblog that supports tagging posts. There''s a has_and_belongs_to_many relationship between posts and tags. I''d like to now reuse those tags for tagging links as well. Where I have a posts_tags table with post_id and tag_id fields, I''d like to
2006 Apr 16
6
still learning maintaining data with join tables
Class Role has_and_belongs_to_many :users Class User has_and_belongs_to_many :roles Class RolesUsers has_and_belongs_to_many :roles has_and_belongs_to_many :users According to the logs...I''m good through here @roles_users = RolesUsers.find(:all, :conditions => ["user_id = ?", params[:users_id]] ) the next section of controller code is a problem...
2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
Hello all, I just ran into something that I think is a bug, and I would like to confirm with the core team whether this is expected/desired behavior or if this is a bug that I should file and develop failing tests for (I doubt I have the active record method_missing fu to actually patch it). Test Scenario: I would like to find or initialize a new user and base the find on the users email
2010 Oct 27
0
Help with routes
Switching our routes file from Rails2 to Rails3 DSl uncovered an odd situation, of my own making, but I am having some difficultly imagining how to fix it. Basically I have a commonplace: user -> user_role (clearance) <- role type arrangement where: User has_many :roles, :through => :clearances has_many :clearances Clearance belongs_to :role belongs_to :user and Role
2006 Jan 17
0
Overriding Delete/Destroy in ActiveRecord
Anybody know how I can override delete/destroy in objects that have has_and_belongs_to_many behavior specified? I''m having issues overriding delete for an ActiveRecord object that contains a has_and_belongs_to_many relationship. Delete and destroy are properly overridden for objects that do not have has_and_belongs_to_many relationships specified, but as soon as I add any the overridden
2006 Apr 20
4
ActiveRecord: Many-to-Many problem
I am trying to make many-to-may relationship on classes Section and Content. Both Content and Section has: has_and_belongs_to_many :contents and has_and_belongs_to_many :sections and I have an exception when trying to access model properties: "undefined method `add_contents'' for #<Section:0xb745c514>" def add_content_entry @section = Section.find(params[:section_id])
2006 Jan 06
0
bug rails activerecord association join
hi, I found a bug in ActiveRecord association SQL INNER JOIN codes. in has_many, has_one, habtm and belongs_to queries the foreign key is determined from the table name of reflection and self. but that''s worng because if you use a global prefix or suffix for your tables the foreign keys will be in format of PREFIX_CLASSNAME_SUFFIX_id which is wrong, because it breaks the advantage of
2006 Nov 09
2
help with join tables and has_and_belongs_to_many
Hi, I have a user model and a privilege model. They have the has_and_belongs_to_many relationship. Here are the model defs: class User < ActiveRecord::Base belongs_to :status has_and_belongs_to_many :privileges end class Privilege < ActiveRecord::Base has_and_belongs_to_many :users end Now I have a migration script to create the join table and populate a few users with some
2006 Jan 04
0
Re: DB Modelling the Rails way - solution by Chris Hall
Hi Chris, Yesterday you kindly submitted an answer to my question on modelling many to many relationships. I''ve briefly tried the proposed solution but so far with no luck. Before I get too involved - I''d like to know if mapping three way :join_tables is "legal" in a Rails sense. I only ask since you put (untested) in your mail and I can''t find any docs on
2006 Aug 02
1
ActiveRecord: find_or_create with has_and_belongs_to_many --
I am attempting to use find_or_create on a foreign table with a has_and_belongs_to_many relationship with my current table. I am doing the following: term = school.terms.find_or_create_by_code("FALL06") the queries in the log show the expected SELECT statement to query if there is a join table record between the school and term with code "FALL06": SELECT * FROM term INNER
2006 Jan 07
4
To Chris Hall - Re: DB Modelling the Rails way - Opinions??
Chris, Finally got time to fully play with your suggestions. Had to re-code a bit of stuff but the concept works - just like a bought one :~). Many thanks for the solution, Kind Regards, Eric. For those curious - here''s what it was about; On Monday 02 January 2006 02:10, Eric Sloane tried to type something like: > Hi, > I''m trying to figure the most efficient way to