Displaying 20 results from an estimated 10000 matches similar to: "Re: CRUD pattern for has_many relationships (forms containin"
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
2006 Dec 20
7
has_many :through does it support collection_singular_ids ?
Good evening list members,
I have the following model:
class Author < ActiveRecord::Base
has_many :authorships
has_many :books, :through => : authorships
end
Should I be able to do the following?
Author.find(:first).book_ids = [1,2,3]
I ask, because it doesn''t. The docs state that it should, but it
doesn''t specialise in the case of a :through
This
2006 Aug 16
0
Testing has_many, :through relationships
Hi All,
This is my first post on this list. I''m a developer working on the
Central Coast of NSW, Australia and came across RSpec via Lachie who
demoed RSpec on Rails at a Sydney rails user group meeting a couple of
months ago. I''m loving the expressiveness of RSpec and can''t really
see myself going back to Test::Unit.
I''ve come across one oddity though. I
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
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 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 Jul 27
0
CRUD, REST and associations
Let''s say I have the model class Reader and Magazine, connected by join
model Subscription. It looks something like this
class Reader < ActiveRecord::Base
has_many :subscriptions, :dependent => :delete_all
has_many :magazines, :through => :subscriptions
validates_presence_of :name
end
class Magazine < ActiveRecord::Base
has_many :subscriptions, :dependent =>
2004 Nov 10
1
List seems to drop empty levels of factors when containin g them
I don't get the same result, do you have a package loaded that would change
the default behavior (such as Hmisc)?
> list(grp.1)
[[1]]
[1] 1 2
Levels: 1 2
> list(grp.1[mask])
[[1]]
[1] 1
Levels: 1 2
> library(Hmisc)
<<snip>>
> list(grp.1[mask])
[[1]]
[1] 1
Levels: 1
--Matt
> version
_
platform i386-pc-mingw32
arch i386
os
2006 Aug 04
3
forms and relationships
i''m still pretty new to rails, and while i''ve been able to hack my way
into having it do what i want so far, i''m not happy with the way my code
looks. on top of that, i''m sure that what i''m doing prlly isn''t the most
efficient either.
one of my biggest problems is probably to do with using relationships
and forms together. i''ve
2006 Feb 07
0
Newbie question: has_many to multiple classes
Hi,
I''m trying to work out how to tackle a particular problem in rails.
I have some data. A lot of data (well not NSA style a lot of data, but
a lot for me: 1Gb at the moment, more to come).
I''m building a ruby application to process and view this data, and have
been working round using rails as a front end - do the heavy lifting
using some maths libraries, then use rails to
2010 Apr 02
6
App_Controller and partial issues with has_many through
I have a User model, a Post model, and an Interest model:
User has_many posts through interests
User has_many interests, dependent destroy
Post has_many users through interests
has_many interests, dependent destroy
Post has_many interests
Interest belongs to Post
Interest belongs to User
Application_Controller is as follows:
class ApplicationController < ActionController::Base
before_filter
2009 May 27
0
Nested Forms with has_many associations with validations
I want to have a parent model that I can add child objects (via a
has_many association) using the rails 2.3 nested form syntax. However,
it seems like rails throws an error during validation of the parent
model if I have a validates_presence_of :parent_id defined in the child
model.
Is the only solution to this to remove the validates_presence_of
:parent_id? This seems like a hack-ish workaround.
2009 Apr 12
0
rails 2.3 nested forms with has_many through checkboxes
I was wondering if anyone knew of a way to combine the new nested
forms in rails 2.3 with a has_many through relationship via
checkboxes. Basically I have a page model, a page_category model and
a category_items join table. Pages have many page categories through
category items. The category_items table is polymorphic so i can use
it for other models who need categories (maybe this is
2009 Aug 01
0
Nested forms and deleting/removing has_many associations
I am using nested forms on person model that has many pictures.
I would like to allow the user to remove on or more of the associated
pictures from the person using nested forms as suggested by Ryan Bates.
However delete will delete the picture not remove the associatioon
I can do it in the controller, but it should be done in the same way as
delete is performed using attribute _delete
Anyone
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
2006 Aug 03
3
Relationships between models.
Hi All,
I think Im having a mental block here. For some reason I just cant get
my head round relationships.
What I have is the following.
4 tables
1) Hosts
2) Software
3) OperatingSystem
4) Company
In my terms (which are most likely wrong) a company can have lots of
hosts, a host has lots of software, a host has one operating system.
So should my models have the following relations in them?
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