similar to: Relationships question (?)

Displaying 20 results from an estimated 14000 matches similar to: "Relationships question (?)"

2006 May 14
4
searching on foreing keys
Hey all, I''m using a simple search function. It''s working great except for foreign keys. I have one table pets (id,name,owner_id) and another table people(id,name) owner_id being a foreign key of pet pointing to people name. here it is on the pet controller: @paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id like
2008 Jul 08
4
Conditional "link_to" helper function - AYUDAME POR FAVOR
Hello, I need to write a function that will return a link only if the current user is the owner. Here is my code... 1. application_helper.rb 2. 3. def link_to_if_owned(owner_id, anchor_text, where_to_go) 4. if current_user.id == owner_id # current user is owner 5. "#{link_to anchor_text, where_to_go}" 6. else 7. anchor 8. end 9. end And
2006 Feb 17
0
Model relationships in tests
I''m finding that its a pain to create yml files for tests where there are relationships between tables/classes. For example, I might have something like this: vehicle.yml red_ford: id:1 owner_id:2 owner.yml ford_owner: id:2 address_id:5 address.yml home_address: id:5 etc. To build up complex test relations, I have to edit all three files, keeping track of the ids /
2008 Jun 13
6
Newbie question on has_many
I have two classes: a Widget and a User. The User has an id that is referenced in two places on the Widget: owner_id and operator_id. How should I structure that reference for has_many? Thanks folks - I appreciate any help on this. --David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2005 Mar 08
1
Adding to model (newbie)
Sorry if this is a really lame question, I''m sure it''s something fairly obvious, but I just can''t see it at the moment... I''m trying to add something simple to the model for a project management/todo list/thing. The DB has ''first_name'' and ''last_name'', and I''d like to have "full_name" available. So -
2006 Nov 26
5
associations help?
I have Users who can "own" Projects. There is only one owner. Users in general can be authorized to view certain projects. Here is my initial stab at this: class User < ActiveRecord::Base has_many :projects # ownership has_many :project_viewers, :dependent => :destroy has_many :projects, :through => :project_viewers, :uniq => true ... end class
2006 Apr 30
3
require "ajax_scaffold" in model error
Hi there, I''ve got installed ajax_scaffold_generator (3.1.2, 2.2.1) Anyway I''m following the example here <http://height1percent.com/ articles/2006/04/18/ajaxscaffold-3-1-0-released> which suggests the following in a model file: -------------------------------------------------------- require ''ajax_scaffold'' class Pet < ActiveRecord::Base
2023 Jul 03
2
[Bug 1691] New: mnl_nlmsg_ok returns true on malformed/incomplete messages leading to potential runtime issues
https://bugzilla.netfilter.org/show_bug.cgi?id=1691 Bug ID: 1691 Summary: mnl_nlmsg_ok returns true on malformed/incomplete messages leading to potential runtime issues Product: libmnl Version: unspecified Hardware: x86_64 OS: All Status: NEW Severity: normal Priority: P5
2019 Oct 16
3
[Bug 1374] New: Add a way to suppress printing of set contents in 'nft list ...' output
https://bugzilla.netfilter.org/show_bug.cgi?id=1374 Bug ID: 1374 Summary: Add a way to suppress printing of set contents in 'nft list ...' output Product: nftables Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5
2004 Aug 09
2
cbq dosen''t shape on MARK for one host.. strange!
Hello all, this is my first post here. Sorry for my english. Gentoo LAN router, 2.4.26-hardened-r2 There are 2 WAN links, one LAN link. I am doing some iptables/routing/tc magic in my scripts. What''s interesting is marking packets traveling from all IP''s in LAN. Interesting commands are: ------------- for ip in `seq 50`; do $IPTABLES -t mangle -A FORWARD -o eth2 -d
2006 Oct 13
1
Edge rails, single table inheritance and keeping multiple classes in a single file
So is the official stance as per edge rails that multiple class definitions must go into separate files? I was trying to use STI with acts_as_attachment, to have all my attachment classes go into a single file, for example: attachment.rb class Attachment < ActiveRecord::Base end class UserPicture < Attachment belongs_to :user, :foreign_key => ''owner_id''
2006 Apr 24
1
Just a couple questions on how I should go about
> I need a simple blog with categories and comments and an archive. I want a > nice posting system, but don''t want it in HTML. Is there something I can add > or make, kind of like BBCODE? http://whytheluckystiff.net/ruby/redcloth/ http://wiki.rubyonrails.org/rails/pages/RedCloth > I pretty much know what else I have to do, but there is one more thing. A > client section.
2007 Jan 22
1
Observed models cause failures with DRBSpec ?
Hi all ! I don''t believe I am the only one using model observers, right ? Well, here''s a nice one: $ drbspec spec . Finished in 0.125322 seconds 1 specification, 0 failures $ drbspec spec F 1) ''A user with an inactive and an active project should be able to return active projects only'' FAILED [] should == [#<Spec::Mocks::Mock:0xb75590bc
2006 Aug 01
0
SEARCHING w JOIN in one-to-ma,y relationship
I am doing a Search in my ''properties'' table on column ''name'' using in my controller : conditions = ["name LIKE ?", "%#{@params[:query]}%"] unless @params[:query].nil? this ''properties'' table has a FK (owner_id) in teh column ''owner'' to link it with the table Users... I can display the owner.name, and
2007 Jul 08
2
datetime_select, is creating an instance of the Time class
Hello It seems that datetime_select, is creating an instance of the Time class. Why would that be? I found this while building a site where people can create vigils (prayer vigils, peace vigils, etc). When I added a validation method that compared start_date to created_at, it generated the error: ArgumentError (comparison of Time with DateTime failed): I was able to put a breakpoint in the
2011 Jul 11
2
Pre-populating association
Hello, I think this is an easy one for the average Rails developer but I''m a bit stuck. I''m creating a simple voting app: any user can create a survey, with any number of questions, and other users can then vote by creating a ballot for that survey. Here''s the modeling: class Survey < ActiveRecord::Base has_many :questions has_many :eligibilities has_many
2006 Feb 21
7
has_many :through failing to save changes
Hi all, I''m messing around with has_many, and has_many :through (on edge rails), using a join model. Branches and Projects join through ProjectsAtBranches. If I do @branch.projects, I can see the associated projects, and visa-versa, if I manually put them in the join table. But I cannot do @branch.projects << Branch.find(blah), or @branch.projects.clear, and then save the
2006 May 09
5
Shared Queue / Exclusive Query Results
My application is going to have a work queue of scheduled tasks stored in the DB. This work queue will be shared across multiple Rails app servers. I need a way to ensure that no two servers get the same jobs if multiple servers pop jobs off the top of the queue simultaneously. Is there a fairly simple way to acheive this? Or do I need to come up with some fancy secondary server to dispatch
2008 Aug 01
2
Is this a many to many relationship??
So i have one table of data, each data object has two owners from the users table. so it''s data table id owner1_id owner2_id --------------------- 5 1 2 10 1 2 owner table id name --------------- 1 bob 2 cornholio so when i pull records from the data table for owner1_id how would i access the name field of owner id 2? -- Posted via
2010 May 14
4
Tricky model situatione
I have two models Club and users. users are regular authenticated users and some of them might create a club. A club can also have members (essentially users) and there are attributes and models that apply to member but not to users. Here is what I have right now. Club => belongs_to :user User => has_many clubs (since a user can host multiple clubs). Now how do I fit this member model