Displaying 20 results from an estimated 10000 matches similar to: "Change to has_many :through associations"
2006 Mar 06
4
Change to set_fixture_class
So, I sat down to use set_fixture_class, and it bombed on the first
thing I tried:
set_fixture_class :content_drafts => "Article::Draft"
I made a quick patch, and I''d appreciate a quick run through your
tests to make sure it doesn''t disturb anything:
http://dev.rubyonrails.org/ticket/4095
As I was typing this, I realized that the string gives us no benefits.
I
2006 May 28
7
Self-referential has_many :through relationship
Hi,
I have a self-referential has_many :through relationship setup to
track relationships between users. Basically relationships are
modeled as a join table with an extra column ''relation''.
create table relationships (
user_id integer unsigned not null,
friend_id integer unsigned not null,
relation char(1) not null,
)
--- relations ---
f = friend
r = request to
2006 Feb 09
2
Polymorphic Associations
If anybody on edge familiar with this could help, that would be "great" :)
I have different types of things I want to be "reviewable". So, instead of
having a slew of HABTM... this new Polymorphic Associations schtick seemed
like the best solution. I have everything setup as I thought it should be
(so I think)... but it doesn''t appear to be working correctly. Here
2006 Mar 01
4
STI, subclasses and callbacks
I have a STI class tree. I want to set some default values (calculated
values so I can''t set it in the database as defaults) on every created
instance regardless of what subclass is actually instantiated. So I
figured adding a after_create callback in the top class in the hierarchy
should do the trick. It seems it doesn''t get called :(
Code:
class SuperClass <
2007 Jul 24
9
will_paginate plugin doesn't work with Association Extensions?
I have:
class Post < ActiveRecord::Base
has_many :comments do
def published
find( :all,
:conditions => {:published => true} )
end
end
end
When in my controller I do
Post.find(:first).comments.published.paginate :page => params[:page]
I get an error
undefined method `paginate'' for []:Array
Is will_paginate supposed to
2006 Oct 15
1
mongrel_send_file gem plugin
served piping hot fresh from my svn repo:
http://svn.techno-weenie.net/projects/mongrel/mongrel_send_file/README
== mongrel_send_file GemPlugin
This is a simple plugin to handle the sending of secure files from a
rails app. Here''s the typical process:
- Rails app authorizes user to download file
- Rails app sets file info in the session, redirects to custom URL
like
2006 Apr 03
2
Problems with STI in has_many/belongs_to in Rails 1.1
I have a problem that surfaced in my attempt to upgrade my application
to Rails 1.1.
We have a STI model on the "belongs_to" side of a has_many/belongs_to
relationship. All my unit tests for this model pass, and the
relationships all seem to work fine.
But in my functional tests, I''m getting errors. I''ve traced it back
into the call to the has_many
2006 Jan 30
1
Multiple associations between tables - do they ever work?
This is really bugging me. How can I get a second association to work
between 2 tables.
I have two models, User and Article. A user has many articles, and an
article belongs to one user. Then I have the "current article", which
is a the article that the user is currently viewing/editing. I want to
track/save this value, so they can come back to the same article if they
log out
2006 Jan 19
2
has_many :through
Has anyone had much experience using the new has_many :though options
that are currently in Edge Rails? I''m looking at using it in my
project but haven''t found much about it.
Kyle
2006 Mar 06
20
How painful is the 1.0 -> 1.1 upgrade going to be?
Does anyone have a sense for how painful the 1.0 -> 1.1 upgrade is
going to be for existing apps? I''m finishing up my first real RoR
application with Rails 1.0. I can live with it staying at that level,
but I really want to use the has_many :through attribute to clean up
some of my code.
I''m not particularly interested in edge Rails, mainly because the
documentation for
2006 Jun 23
2
polymorphic challenge
Hello All,
I have a little challenge and I am not sure if this is even possible
I am working on a dating/event site and few functionalities are similar
that I want to centralize them.
We have users which can have
- favorite users
- interest list
- blocked users
All these relations are like;
User <-> Relation <-> User
I was thinking I could have a class called Relation (with a
2006 Jun 11
2
Problem with Acts_As_Attachment
Hi,
I have installed the acts_as_authenticated plugin from technoweenie, but
when I run the tests I get an error (running windoze)
-- create_table(:attachments, {:force=>true})
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'':
no
such file to load -- sqlite (MissingSourceFile)
I found the require statement in test/abstract_unit.rb
2006 Jan 20
11
Userstamp Plugin
I''m pleased to announce a new plugin for Rails: Userstamp. You can read my
blog post at http://www.delynnberry.com/articles/2006/01/20/userstamp-plugin
and/or read all about it at the perminant page
http://www.delynnberry.com/pages/userstamp. Any comments or suggestions for
improvement are much appreciated.
--
DeLynn Berry
delynn@gmail.com
http://www.delynnberry.com
A dump of the Readme
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 Nov 02
4
Still Having Problems With :through When Going To Same Table... Help... please :-(
I am having a problem with doing a :through that goes back to the same table.
The following are my two classes:
>>>>>
class User < ActiveRecord::Base
has_many :spanks
has_many :spanked, :through => :spanks, :source => :spanked_user
has_many :was_spanked_by, :through => :spanks, :source => :user
end
class Spank < ActiveRecord::Base
belongs_to :spanker,
2006 Mar 14
2
acts_as_paranoid and :include
Will the find from acts_as_paranoid filter down to an :include?
For instance
class parent
acts_as_paranoid
has_many: children
end
and
class child
acts_as_paranoid
belongs_to :parent
end
Then if you
Parent.find(:all, :include => children)
you will get all the children if they are deleted or not. I guess the find
that filters out the deleted_at is null does not filter down to the includes
2006 Jun 13
0
question about saving associations when using has_many :through
I''ve got a User model and a Book model. A user is required to submit
books each month to be reviewed by other users. I have the following
relationships defined:
# the join model
book_review.rb
belongs_to :user
belongs_to :book
end
book.rb
# each book is reviewed by many users. This allows us to get the BookReview
# objects associated with this book
has_many :book_reviews,
2006 Feb 15
10
STI Question
Hi everyone,
I have 3 types of people (for now):
Staff
Faculty
Students
To break them up into classes, but keep them in the same People table,
I''ve broken them up like so (code and ''ends'' snipped):
class Person < ActiveRecord::Base
class Employee < Person
class Staff < Employee
class Faculty < Employee
class Student < Employee
So, when I insert
2006 Jan 22
2
suggest for "ambiguous column" when JOIN associated tables
Today I face with incorrect behavior in ActiveRecord.
It take place when I try to use :include parameter for .find method.
Where are two typical cases:
1. You have record with self-referential joins
CREATE TABLE keywords (id, group_id);
class Keyword < ActiveRecord::Base
belongs_to :group,
:class_name => "Keyword",
:foreign_key =>
2006 Sep 03
1
New Technique: Subsets of has_many Associations
I just now thought of this, and sure enough it works like a charm (at
least so far in my limited testing):
has_many :events, :dependent => :delete_all
has_many :upcoming_events, :class_name => "Event", :conditions =>
"date > NOW()"
The purpose of this is that it makes eager loading of subsets of
associations possible without replacing all the magic of the