Displaying 20 results from an estimated 100 matches similar to: "ActiveRecord: find_or_create with has_and_belongs_to_many --"
2007 Mar 16
1
Polymorphic find_or_create bug
Today I just spent 3 hours (and before a demo!) trying to figure out
why my polymorphic association fields were breaking.
Turns out someone else put in a patch for this 6 months ago. I''m not
sure if its the same solution I''d use... I''d rather find_or_create
attempt to use AssociationProxy#build if its available and only
Base#new if we''re not on a proxy.
2009 Oct 11
0
Nested Attributes and find_or_create
Hi,
I''m using the new Nested Attributes to edit my models. It''s a
complicated relationship between 5 different models which are subclassed
from a ''Metadata'' model. They all have has_and_belongs_to_many
relationships with the model I am trying to edit.
Unfortunately when I add a new nested attribute, it creates a new row in
the database. I need it to check up
2010 Jul 12
0
[Patch][Issue #5097] attributeless find_or_create/find_or_initialize
This patch relaxes DynamicFinderMatch to recognize find_or_create /
find_or_initialize without a trailing _by_attribute_list. I''ve found
this useful when the relevant attributes have already been built up
through a chain of associations or named scopes.
Please review, thank you!
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2012 Feb 22
3
Parent id for find_or_create method
Rails 3.1.3
I have tables, Video and Script having association,
Video 1 --- n Script
So, every Script needs the parent id, in this case, video_id.
If I simply create a new Script instance, the view renders as follows.
<%= render :partial => "new_script", :locals => { :script =>
Script.new(:video_id => @video.id)} %>
which works fine. Now I would like to
2007 Oct 23
0
9 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_style_sheet.c libswfdec/swfdec_style_sheet.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie.h
libswfdec/swfdec_as_strings.c | 2 +
libswfdec/swfdec_html_parser.c | 41 ++++++++++++++++++++---
libswfdec/swfdec_style_sheet.c | 47 +++++++++++++++++++++++++++
libswfdec/swfdec_style_sheet.h | 6 +++
libswfdec/swfdec_text_field_movie.c | 24 +++++++++++--
libswfdec/swfdec_text_field_movie.h | 2 +
libswfdec/swfdec_text_field_movie_as.c |
2010 Mar 13
6
Find first or create
Is there any ActiveRecord''s dynamic finder that can allow me to find
first association or create it if it doesn''t exist. Something like this
(not this code is conceptual - it does not work!):
Comment.posts.find_or_create(:first)
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Oct 12
3
Help with observer_form , javascript error
I''ve set up an observer form, it is not working nor throwing error at least
in loading the page.
The Firefox javascript console is showing this error:
Error: missing } after property list
Source File: http://localhost:3000/ajaxsearch/list
Line: 165, Column: 45
Source Code:
hide(''roller'')}, parameters:''Form.serialize(''asearch'')='' +
2006 Jun 15
1
has_and_belongs_to_many
My web server has a list of users, and each of them has a collection of
books. I want to save some certain number of books for each user,
including the book''s name, author, and display the information for the
user.
Which method should I use to store the subject information into each
user subject?
Do I have to create arrays to store it?
Thanks for help!
--
Posted via
2006 May 08
2
Queries with has_and_belongs_to_many relationship
I was able to create a has_and_belongs_to_many relationship for my app,
but now I''m not too sure how to write queries for it.
Basically, I have a table ''courses'' that has_and_belongs_to_many
''categories'' and vice versa
So I''m trying to figure out how I would find only the courses that
belong to a category that I specify.
Let''s
2006 May 26
0
has_and_belongs_to_many with fk constraints?
Hi folks,
I''m wondering if it''s possible to use foreign key constraints on the join
tables of a has_and_belongs_to_many relation. Specifically, I get this
error when I try and delete a model I''m using, named saved_search, which is
many-to-many with neighborhoods. Any ideas? Thanks for any help. :-)
-Eric
Code:
@saved_search.destroy
Error:
Mupdate or delete on
2006 Apr 01
3
has_and_belongs_to_many construction
Hi there,
I''ve got a table construction like this:
presentation contactstate
Hilton new
Mc Donalds emailed
etc. called
visited
etc.
Now i''ve created an join table presentationcontactstate with extra
fields like comment and date time. so i know for example when i called a
specific presentation.
Now
2006 Apr 06
3
has_and_belongs_to_many find
Say I have a post model that has_and_belongs_to_many :categories, and a
category model that has_and_belongs_to_many :posts. So I have a
categories_posts table to do the join. That''s all find and dandy.
However I want to be able to find all the posts that belong to a
specific category.
I tried Post.find_by_category(:id) but that doesn''t work.
Does anyone have any insight?
2006 Apr 21
0
collection_select has_and_belongs_to_many update_attributes
I know there have been threads on this before but I was thinking
shouldn''t multiple collection_select automatically update habtm
relations when you update_attributes?
In order to get multiple collection_select to work I use:
collection_select(:user, :group_ids, Group.find(:all), :id,
:name,{},{:multiple=>'''',:name=>''group[id][]''})
In fact if I
2006 Mar 07
1
has_and_belongs_to_many tags
I''m trying to create a search where I can find pages by their tag name.
Here''s a sample of my code (not working).
@tags = Page.find(:all, :conditions => ["#{:tag.name} LIKE ?",''%'' +
@params[''searchtags''] + ''%'' ])
My enviroment:
I''ve got a table called tags, and a table called pages, both with a
2006 Mar 09
2
has_and_belongs_to_many -- how to create test fixtures?
Hallo -- can anyone offer me any pointers as to I should handle
many-to-many relationships in Rails tests?
Cheers,
doug.
--
Posted via http://www.ruby-forum.com/.
2006 Feb 10
0
Deleting the association entry for has_and_belongs_to_many when one object is destroyed
I know that for has_many, and has_one.
I can do :dependent => true and the associated object will be
destroyed when the main object is destroyed.
However, there does not seem to be a dependent like option for
has_and_belongs_to_many.
Is there one I do not know of? Is there a simple solution to this?
Thanks,
Brian
--
www.kenlet.com
2006 Jan 03
0
has_and_belongs_to_many include problem
hey,
i have users who are in groups, and i have a search form, where i can search on
group, user lastname, and user firstname.
All this is also with pagination.
these are my models
class User < ActiveRecord::Base
has_and_belongs_to_many :groups
end
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end
in my controller i do this
THIS works (but in need pagination)
@users2
2006 Jan 16
0
belongs_to with has_and_belongs_to_many
I''m having a problem with belongs_to and has_and_belongs_to_many.
Here''s a brief summary of the models involved:
class Member < ActiveRecord::Base
set_primary_key ''member_id''
has_and_belongs_to_many :projects, :join_table => ''projects__members''
has_many :projects, :foreign_key => ''created_by''
end
class
2005 Dec 14
0
how to get these records in has_and_belongs_to_many relation
hey,
i my database i have users and groups, each user can get in different groups
my db structure:
table groups: id, name, basegroup, firm_id
table users: id, firstname, lastname, email
table groups_users: group_id, users_id
my relation is a many to many:
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end
class User < ActiveRecord::Base
has_and_belongs_to_many
2005 Dec 20
0
validates_uniqueness_of on has_and_belongs_to_many
I am trying to create a model that allows only unique assets to be
added to a category. However, they could be added again to a different
category. Finally, an asset can be shared across many categories. So
my question is how do you check the uniqueness across a join table?
This does not compile....
has_and_belongs_to_many :categories, :foreign_key => ''asset_id''