Displaying 20 results from an estimated 900 matches similar to: "HABTM: two habtm''s between the same two tables"
2008 Mar 07
3
Boolean circles..
Hi,
This is just kindof a RoR question, but since you all potentially do
the same things as I do, I thought I''ll ask here..
Im trying to use the boolean type in the database. Migrations is no
problem, it even converts the 0/1 values from my import CSV to false
and true.
However, I cannot make the :conditions part of a find work:
Loading development environment (Rails 2.0.2)
>> c
2005 Oct 26
2
validates_associated ... doesn't
Hi,
I think I''m missing some fundamental information here so hopefully
someone can help me. I have a model Club which has many members,
members of course belong to a Club. I''d like to ensure that when a
members is saved (saved/created/updated) only valid club_id''s are accepted.
I have a Club model (simplified) like this:
class Club < ActiveRecord::Base
2006 Jan 02
5
DB Modelling the Rails way - Opinions??
Hi,
I''m trying to figure the most efficient way to model the following. I
can think of at least two ways to relate the tables but from a
client/server perspective! I''m wondering how to best (and
elegantly)relate them from an AR perspective.
A project has many people,
A person can work on many projects at any time,
A project has many roles,
A role is performed by a person,
A
2006 Apr 17
1
database design Q
I am in the middle of setting up mysql database for my RoR application.
and here is some questions in my mind hope you can help.
1. this is a photoblog story telling like system, where people can creat
their own groups
the database tables are: people, groups, articls, pictures
People to Groups are many-to-many relationships
People to Articles are one-to-many
Group to Articles are one-to-many
2007 Feb 24
0
after_create not creating the right object
I have 2 tables... club and forum, which use the "type" as I''m
subclassing the Club and Forum objects. Tables are:
clubs:
id
title
type
forums:
id
club_id
title
type
I''ve put an "after_create" callback in the Club as Club has_one Forum:
class Club < ActiveRecord::Base
after_create :create_forum
has_one :forum
def self.create_forum
# create it
2008 Mar 07
2
Trouble using RESTful helper
Hi,
I am trying to get into this REST thing, I have a nested resource
whith the following route:
ActionController::Routing::Routes.draw do |map|
map.resources :members
map.resources :clubs do |club|
club.resources :members
end
map.connect '':controller/:action/:id''
map.connect '':controller/:action/:id.:format''
end
Everything worked ok for this
2006 Jan 21
7
n-way joins
Hi,
I''m somewhat of a Rails newbie and am trying to understand how to
formulate n-way (3 or 4 way) joins in Rails (where the join tables
contain extra data as well.)
Let me give you my basic entities:
foos
id - pk
name - unique
bars
id - pk
name - unique
bazs
id - pk
name - unique
frozs
id - pk
name - unique
then i have two separate join tables:
foos_bars_bazs - 3 way join
2006 Apr 20
2
table that have many-to-may relationship to itself
In a social netowrk data model, users belongs other users, and can have
many friends as users, so it is a many to many relatioship.
the class definition could be
class User < ApplicationController
has_mang_ang_belongs_to users
But how it looks like in the mysql database tables in a "joined" users
table.
The question really is: what is the table looks like when a model has
2006 Jan 19
5
limits of has_and_belongs_to_many
I''m experimenting with Rails on the Recipes example first before I dive
into applying it to my intended application. I''m exploring which will be
more work: to rename all the primary id''s in the legacy database, or to
work around the fact that the primary id''s are not called ''id'' within
RoR instead.
I''ve been successful in using a
2006 Feb 24
6
Changes to Class File Not Being Recognized by Webrick
Newbie, having good luck with Dave Thomas'' book ''Depot'' application
until I discovered that changes to one of my .rb class files are not
being recognized until I bounce the webrick server.
Any ideas on this? Thanks.
--
Posted via http://www.ruby-forum.com/.
2006 Feb 21
7
Self-referencial habtm relationship
Heyo!
I am setting up a self-referencial habtm relationship with the users
of my app. I am using Chad Fowler''s "Rails Recipes" to get me started,
and everything works great with the join table "people_friends". I add
friends by doing somebody.friends << somebodyelse. However, with my
app, there is an approval process so my join table has columns
person_id,
2006 Jun 15
5
gem install rails locally without Internet?
I''ve got a machine that cannot be connected to the Internet (think
security precautions in a bank) and am thus trying to install rails
using
gem install rails-1.1.2.gem
thinking this would work. It does not. I get errors about
ActiveSupport module missing. It makes it sound like I have to get
separate gems for ActiveSupport, ActiveRecord, etc., and install them
all one at a
2006 Apr 18
6
Best Practice for Returning to Calling Page?
I have a partial, it''s a shopping cart display, it''s designed to appear
on several different pages of my site.
One of the buttons on the shopping cart empties the cart, and then I
want the calling page to redisplay.
In other words, the cart controller needs to return the visitor to the
same page -- however since the cart could appear on any given page, this
has to be
2009 Feb 27
4
Optimize for loop / find last record for each person
I want to find the last record for each person_id in a data frame
(from a SQL database) ordered by date. Is there a better way than
this for loop?
for (i in 2:length(history[,1])) {
if (history[i, "person_id"] == history[i - 1, "person_id"])
history[i, "order"] = history[i - 1, "order"] + 1 # same person
else
history[i,
2007 May 16
5
drop a letter
hello,
how can I do to drop C from this character "C325" ?
_____________________________________________________________________________
[[alternative HTML version deleted]]
2006 Jan 09
3
Design Question
I am sure some of you can give me an insight into this. This is more
towards the database design for the scenario below:
Say for example,
I have a person table and this person can have different address types.
One could be Home and the other could be say Office.
Should be model this
Table people
id
fname
lname
Table addresses
id
person_id
addr1
addr2
....
or
Table people
id
fname
lname
2006 May 26
3
Breakdowns in has_many abstraction
I discovered an interesting aspect of has_many behavior that I''m
struggling to work around. I''m not sure if I''m doing something wrong,
or if it''s a legitimate bug, or if it''s an inherent part of Rails that
I just have to learn to deal with.
It boils down to these two problems:
- changes in collection objects (i.e. models that belong_to a
container
2010 Aug 10
4
(Dreaded) STI, belongs_to
Having problems with STI. Names below have been changed to protect the
innocent. Imagine a system that allows someone to apply for one of two
different types of school scholarships. Each scholarship goes through a
different review process, represented by a state machine (this is not a
state machine question). So there are two state machine classes that
differ slightly and subclass a generic
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set
for the correct columns; but the tests I''ve come up with so far seem
to fail to fail when I expect. I came across this old message from
this list:
http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html
Which seemed like a plausible example, but my attempt (modeled on the
example)
2006 Mar 03
2
newbie scaffold question
I''ve got a database with several tables. I''d like to create scaffolding
for separate CRUD interfaces for several of these tables. I''m hoping
that the scaffold generator can create the CRUD code for all these
tables in ONE controller, but I don''t know how to tell it to do that, if
it can.
Can anyone verify if this is possible?
Thanks,
David
--
Posted via