Displaying 20 results from an estimated 20000 matches similar to: "Reloading a model in test mode"
2011 Feb 26
1
How to manage the form of a model that has two foreign keys
Hi,
Basically I have two models: User and Godfather. The godfather table
has three columns:
- user_id (FK --> User)
- user_godfather_id (FK --> User)
- description (text)
Inside each model class, I am adding the following associations:
class User < ActiveRecord::Base
has_many :godfathers # for user_id
has_many :godfathers, :foreign_key =>
2006 Mar 15
3
Self-referential join model does not work
I have been trying to model a labeled graph using ActiveRecord (trunk
version). Basically, I have a ''Node'' model which represents a node linking
to other nodes. Links (aka edges) are labeled (i.e., have a ''label''
attribute and other behavior). Thus I decided to model edges as an ''Edge''
model and use a ''has_many :trough''
2006 Sep 22
2
possible to create polymorphic relationship with STI models?
I would like to associate a ‘product’ model with 3 models inherited from
‘image’: part, action and accessory.
I have it working with Has_many :through relating products to images
through attachments, I then have to determine the ‘type’ of the STI
extension. This means i have to go product.images. While this is ok, i
can see it getting tricky when i want to go products.images <<
2006 Mar 24
2
Change to has_many :through associations
Hi everyone. I''ve made a default change to has_many :through
associations that I felt was important to make before they''re
released. This is after some tickets and confusion I''ve seen
regarding has_many :through.
class Connection < ActiveRecord::Base
belongs_to :user
belongs_to :channel
end
class Channel < ActiveRecord::Base
has_many :connections
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 Jan 20
1
stack level too deep from has_many / belongs_to relationship
I have the following 3 models (2 models joined by an intermediate):
1. class Exercise < ActiveRecord::Base
2. has_many :routines, :class_name=>''RoutineExercise''
3. end
1. class Routine < ActiveRecord::Base
2. has_many :exercises,
3. :class_name=>''RoutineExercise'',
4. :order=>''position''
5. end
1. class
2006 May 18
1
repeating has_many calls on the same model
Hi,
I currently have a model with (amongst others) the following declarations in it:
has_many :live_action_personnel,
:class_name => "Credit",
:include => :credit_type,
:order => ''credit_types.position, credits.position ASC'',
:group =>
2006 Mar 02
1
ActiveRecord in modules & associations
I''d like to organise my active records into modules but can''t get the
associations to work. The doc says that associations within the same
module should work. I''ve tried using the class_name option too but still
doesn''t work.
Can anyone help?
For example
module Mod1
class Animal < ActiveRecord::Base
has_many :dogs, :class_name =>
2006 Dec 22
2
Relating Namespaced Models
I am dealing with a large project. I use a lot of STI and therfore have
a lot of models. I''d like to use namespaces to help organize my models
but am having trouble getting started.
I have a base model Term::Base located in /app/models/term/base.rb:
class Term::Base < ActiveRecord::Base
set_table_name "terms"
end
I have a non-namespaced client model:
class Client <
2011 Jun 11
0
problems with geom_vline, histograms, scale=free and facets in ggplot
Dear list,
I?m having a little trouble with adding vertical lines to a histogram.
I need to draw a matrix of histograms (using facets), and in each
histogram add a vertical line indicating the mean value of the data in
each facet. According to the last example in the geom_hline help, to
display different lines in each facet I need to provide a data frame.
I modified this example to make a plot
2010 Aug 19
1
has_many :through question
I am trying to create an association table using the ":through" option
in "has_many" but not having success. I have created the necessary
migrations of the association tables and run rake db:migrate
I have the following model:
class Group < ActiveRecord::Base
has_many :users, :through => :group_user
has_many :invites, :through => :group_invite, :class_name =>
2013 Oct 12
2
Order of factors with facets in ggplot2
Hello,
I'd like to produce a ggplot where the order of factors within facets is
based on the average of another variable.
Here's a reproducible example. My problem is that the factors are ordered
similarly in both facets. I would like to have, within each facet of `f1',
boxplots for 'x' within each factor `f2', where the boxplots are ordered
based on the average of x
2006 Mar 23
3
Newbie: ''find'' across multiple relationships
For security purposes, I often want to find objects that are ''visible''.
e.g.
class Person < ActiveRecord::Base
has_many :x
end
...
@person.x.find(params[:id]) as opposed to X.find([params[:id]). Simple
enough for me.
My question:
Say we have -
class Person < ActiveRecord::Base
has_many :x, :class_name ''Z'', ....
has_many :y, :class_name
2008 Jun 17
1
ggplot facet spacing, wrapping
I'm running into some problems with the spacing of some faceted ggplot plots.
I have a number of time series faceted to be one above another, but the
scale labels of the y axes all clobber each other at the bottom/top of each.
for example, try:
qplot(x, y, data = data.frame(x = 1:10, y = 1:10, size = 1:10), facets =
size ~ ., size = size) + scale_x_continuous(breaks = 1:10) +
2007 Jun 18
0
Problem with belongs_to associations validating associated class: bug in rails in development mode?
Hi all,
I''m using rails version 1.2.3.
I have the following association in my View class
belongs_to :viewer, :class_name => ''User'', :foreign_key => :viewer_id
And of course i have a User model class defined to.
The problem was that when i tried to use this association it would
only work once.
At the second try, i would get the following strange error:
2008 Feb 27
1
how to specify ggplot2 facet plot order
Hi, new to R and ggplot2. I've been trying to get a facet plot in which the
order of the facets is as I require, rather than ordered numerically,
alphabetically, by Roman numerals, mean (answers to these were posted here
after much searching). Here's some test code to demonstrate what I get.
series = c('C2','C4','C8','C10','C15','C20')
ids =
2006 Apr 10
0
Inheriting data from one model to another
Hello
I''ve been struggling with something for hours that I thought would be
a simple job. Hopefully somebody can shed some light on what I''m
trying to do :o)
First of all I''ll explain what I''m trying to achieve. In a store
application I want to have products and product variations. A product
variation should inherit all of its properties from product unless
2010 Sep 11
1
Setting scales for ggplot2 with facets
Faceting in ggplot2 seems to permit different scales for different
facets, but I fail
to see how one could control ylim and xlim ranges for each facet
separately.
For instance, I would like to set the ylim = c(0,10) for facet "A"
and ylim = c(42,102) for facet "B". Since the data is out of these
ranges,
setting facet_grid(factor ~ ., scales = "free_y") does not
2012 Feb 14
2
Model with 2 foreign keys
Hi All,
I''d like to integrate a simple user-oriented messaging system into my
app.
I have a Message model, with :from_user_id, and :to_user_id (for the
user that sent and the user that recieved the message).
Obivously, (User) has_many :messages will fetch the messages that a
certain user has created, but not the ones that they have been sent.
Currently, I have this:
has_many :messages,
2006 Jan 28
0
having problems to map a existing schema in model classes
Hi, I?m doing a project for a company (my first big project in rails).
The company alredy has a database schema, with lots of data, so I don?t
want to change the database schema, but I don?t know how to map some
associations.
Example:
Table: application
Primary Key: idapplication
Table: module
Primary Key: idmodule
Foreign Key: idapplication References aplicattion: idapplication
Table: