similar to: Testing has_many, :through relationships

Displaying 20 results from an estimated 5000 matches similar to: "Testing has_many, :through relationships"

2007 May 10
2
Problem with translator
Hi, Just installed 0.9.4 (from 0.8 series) and ran the spec translator. It messed up specs that had the should include() where the argument to include is a string (using no parens for the arg) IOW, given: context "OldSchool" do class OldSchool attr_accessor collection def initialize @collection = [] end def add_new(item)
2006 Nov 07
3
include Helper in context?
Brandon, can you get your Helpers to work in rspec 0.7 ? I''m including them in the context but the render fails to see it. If you have it working, I''ll go back and bang my head against it some more, otherwise I''ll file a bug! Many thanks, Jerry context "account/login (view)" do include StandardHelpers specify ''displays title
2006 Aug 15
0
has_many relationships and minimums
Hi, New to Rails and the list. Quick questions regarding has_many relationships that require at least 1 child. I''m aware of validate_size_of and use this to make sure that the parent is not saved without at least one child. Question is, is there some Rails magic to help when removing children to ensure the last one is not removed? Currently I''m calling something like this in my
2006 Sep 14
1
acts_as_ferret with has_many :through relationships?
I am currently using acts_as_ferret to search on a Posts table (title and content fields). These posts also have tags (with has_many :tags, :through => :questions_tags). I can''t figure out how to get acts_as_ferret to work with that relationship and allow searching of title, content, And tags at the same time (with the ability to set boost as well). Can this be done? -- Posted via
2006 Jun 07
2
destroy on has_many relationships.
i need to delete a record from the database and delete all of it''s children as well. is there a method for this? right now, i am finding all the children with the parent_id and destroying them first and then destroying the parent. seems like there would be a better way to do this but i can''t seem to figure it out. thanks, josh -- Posted via http://www.ruby-forum.com/.
2006 Apr 22
0
Re: CRUD pattern for has_many relationships (forms containin
Hi Christos, I''ve seen you message in the mailing list archive and I''m trying to achieve the same behaviour. Did you progress in your knowledge of the problem this you last posted? It seems the mailing list hasn''t been that helpful to you. Maybe we can work out a solution by us two. Cheers, gilles
2005 Nov 09
0
Sorting has_many relationships
Hi Railers! I''m building a new website for our bar-foos-league (league for foosball players who play in bars in Zurich, Switzerland ;-) Being a bit of a noob when it comes to rails and web development in general, I''ve come across a few questions. One concerns sorting of a has_many relationship, for instance. I''ve got a League model, which has_many TeamConfigs
2008 Oct 28
4
patch: list shared namespace
Hi, I've been working on a patch for dovecot 1.2 from the Kolab branch (http://hg.intevation.org/kolab/dovecot-1.2_kolab-branch/) that implements listing of shared namespaces. I've got something that works in some basic way but is still missing some pieces. See the attached patch, which also contains some installation and configuration notes. Implementation notes: One of the main
2006 Apr 05
3
CRUD pattern for has_many relationships (forms containing collections)?
Hello folks! Beare with me for a second, while I explain my problem. Assuming we have the trivial model of class Author has_many :books end class Book end How do people go about creating the authors/edit and authors/new views if you want to be able to add and remove arbitrary amount of Books at Author creation and edit time? What I mean by this is that I go to
2007 Feb 13
3
"should.be_in [values]" and "each_should_satisfy"
Hi! I just started using RSpec and have some question that I couldn''t find answers to. If I have a result that can have two valid values, is there a better way of writing the following assertion? [value1,value2].should_include actual Is there a more elegant way of performing should_satisfy on a collection, for example I currently use something like collection.each {|x|
2006 May 16
2
Validate Before Delete
I have an Order model with a ''status'' column. What I want to be able to do is validate that the status of the Order is not completed before it is allowed to be deleted. I tried the following method in my Model, but it appears that this only works for an :update or :create on the record. Anyone know how to do this, and if it should be in the model or the controller?
2006 Jun 27
0
Sydney ROR Meetup - Wednesday 28th June 2006
Hi All, Sorry for the late notice. We have a ROR meetup organised for this Wednesday 28/06/06 from 7pm. I''ll be giving a short talk on using Topfunky''s ActiveRecord fixtures to remotely load production data via Capistrano, and the rest of the evening is currently open - if you have something you''d like to discuss please email Jason Crane (jason [at] codespike.com).
2007 Oct 04
7
Using Predicates to look at an array..
Hi all, I have an array of shipping_type''s being returned, and I want to see what is in there. In the past I have done: shipping_type.include?(Cart::SHIPPING_TYPE_REGULAR).should be_true This works, but looks really ugly.. It just doesn''t roll of the tongue very well. I then looked up the use of Predicates, which I had been using, but hadn''t realized:
2006 May 09
11
model filter?
Hi All, Is there a way to filter / modify the output of a model class before it''s returned to controller/view that''s calling it? Example: I have a field phone_number which I always want to preformat using the number_to_phone() helper.... Any help is appriciated. Thanks! -- Posted via http://www.ruby-forum.com/.
2007 Apr 03
2
has_many :through associated object ids assignment error
Hi, I have the following situation: class Article < ActiveRecord::Base has_many :readings has_many :users, :through => :readings end class Reading < ActiveRecord::Base belongs_to :article belongs_to :user end Now what I''m trying to do is: article = Article.new article.save! # user ids 1,2,3 exist in database, as does the article article.user_ids = [ 1, 2, 3 ] But I
2005 Dec 27
0
How do I combine :finder_sql and :conditions to perform a sub-search on a custom has_many relationship?
I''m sure there''s something right under my nose that I''m missing. I have two tables with two parallel one-to-many relationships. I wish to use the :finder_sql parameter to essentially ''or'' the two foreign keys. What isn''t working for me is performing a ''sub-search''. Let''s say the tables are "stores" and
2005 Dec 26
2
Dynamic order on has_many relationship?
I was wondering if it''s possible to some how control the :order given on a has_many depending on another attribute? Or do I need to just create multiple has_many relationships pointing to the same table but with different orders and then select which one I use in the controller instead? e.g class Category < AR::B has_many :products, :order => //something magical?// end
2011 Jun 22
0
has_many relationship in Gem
Hello, I am creating a gem in which I need to add a new has_many relationships: ... included do |base| base.has_many :foos end def some_method self.foos # end ... Here Foo is a model I created and it is places in app/models/Foo.rb I wonder if I can use syntax like the line marked with #? If yes, I got NoMethodError for using "self.foos" when writing rspec
2010 Jan 08
1
problem using build with has_many :through relationship
Hello all, I''m having problems creating a new record with has_many :through My application is quite complicated so I''ll try to explain it as easy as I can. I have a many to many relationship with Projects, IRBs and Reviews. Where reviews is the joined model. In the new project view, I have a link (add IRB). This will add an a list of IRBs to the new project form. I have visited
2008 Jan 18
2
has_many :through with self-referencial AND polymorphism
Hello, despite many readings I still don''t understand how to solve my problem. I have Publication, Picture, File classes A Publication can be related (a one way relation, like a www link) with another Publication, Picture or File I tried this : Publication : has_many :related_elements, :dependent => :destroy, :foreign_key => :publication_id has_many :related, :through =>