Displaying 20 results from an estimated 9000 matches similar to: "ActiveRecord in modules & associations"
2006 Feb 14
6
Multiple associations to the same class
Hi,
I cannot seem to create associations like this:
class Project < ActiveRecord::Base
belongs_to :manager, :class_name => ''User'', :foreign_key => ''manager''
belongs_to :liaison, :class_name => ''User'', :foreign_key => ''liaison''
end
p = Project.new
p.manager
=> 1
trying to retrieve associated objects
2006 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails
development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would
kick the tires on Rails to see if it can speed up development for internal
applications. Anyway, I am running into a problem that is just driving me
crazy and everything I read on the net doesn''t seem to help. I was hoping
someone here might
2012 May 03
3
inheritance with rails.
Hello.
I''ve read about examples on inheritance with rails.
Here is an example:
http://juixe.com/techknow/index.php/2006/06/03/rails-single-table-inheritance/
The way is to add a type field in the table.
So if I have an Animal class with an attribute name, I can inherit
from this class like:
Dog < Animal, Cat < Animal, and so on.
With the type field in the table I can do Dog.all,
2010 Jan 28
2
Data.frame manipulation
Hi All,
I'm conducting a meta-analysis and have taken a data.frame with multiple
rows per
study (for each effect size) and performed a weighted average of effect size
for
each study. This results in a reduced # of rows. I am particularly
interested in
simply reducing the additional variables in the data.frame to the first row
of the
corresponding id variable. For example:
2009 Mar 05
1
problems with nls?
I need to make nonlinear regression with the posterior script, but how is the
problem? I have error in library (nls), package 'nls' has been merged into
'stats'.
I need help?
What other forms I have to make nonlinear regression? and how I find to
calculate statistics y residuals, scatterplot.
thanks
SCRIPT
ros<-read.table("Dataset.csv",header=T,sep=",")
2012 Jun 29
1
number of items to replace is not a multiple of replacement length
Hello,
I'm a complete newbie to R so sorry if this is too basic..:-S
I have to modify some scripts someone else did to make it work with my data.
For some reason, one of the scripts which were supposed to work is not, and
I get the error message "number of items to replace is not a multiple of
replacement length".
The script is this one:
*open_lpj_nc_gpp <-
2010 Feb 20
3
aggregating using 'with' function
Hi All,
I am interested in aggregating a data frame based on 2
categories--mean effect size (r) for each 'id's' 'mod1'. The
'with' function works well when aggregating on one category (e.g.,
based on 'id' below) but doesnt work if I try 2 categories. How can
this be accomplished?
# sample data
id<-c(1,1,1,rep(4:12))
n<-c(10,20,13,22,28,12,12,36,19,12,
2006 Mar 14
1
Ordered logistic regression in R vs in SAS
I tried the following ordered logistic regression in R:
mod1 <- polr(altitude~sp + wind_dir + wind_speed + hr, data=altioot)
But when I asked The summary of my regression I got the folloing error message:
> summary (mod1)
Re-fitting to get Hessian
Error in optim(start, fmin, gmin, method = "BFGS", hessian = Hess, ...) :
the initial value of 'vmin' is not
2008 Nov 19
3
Overwriting / Decorating ActiveRecord association accessor
Hi,
I am trying to overwrite the accessor of a has_many association.
Basically my class looks like this:
class Person
has_many :emails
has_one :link, :class_name => ''PersonProxy''
def emails_with_link
link.emails + emails_without_link
end
alias_method_chain :emails, :link
end
Now that works fine if I only access the collection like
>>
2006 Oct 04
1
extracting nested variances from lme4 model
I have a model:
mod1<-lmer( x ~ (1|rtr)+ trth/(1|cs) , data=dtf) #
Here, cs and rtr are crossed random effects.
cs 1-5 are of type TRUE, cs 6-10 are of type FALSE,
so cs is nested in trth, which is fixed.
So for cs I should get a fit for 1-5 and 6-10.
This appears to be the case from the random effects:
> mean( ranef(mod1)$cs[[1]][1:5] )
[1] -2.498002e-16
> var(
2010 Feb 15
2
creating functions question
Hi All,
I am interested in creating a function that will take x number of lm
objects and automate the comparison of each model (using anova). Here
is a simple example (the actual function will involve more than what
Im presenting but is irrelevant for the example):
# sample data:
id<-rep(1:20)
n<-c(10,20,13,22,28,12,12,36,19,12,36,75,33,121,37,14,40,16,14,20)
2009 Jun 17
2
djustment values not defined
Hello,
I am using
mod1 <- lrm(y~x1+x2,na.action=na.pass,method="lrm.fit")
summary(mod1)
and I've got the following error:
Error in summary.Design(mod1) : adjustment values not defined here or with datadist for x1 x2
Many thank,
Amor
[[alternative HTML version deleted]]
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 Nov 11
1
predict.lda is missing ?
I'm trying to classify some observations using lda and I'm getting a
strange error. I loaded the MASS package and created a model like so:
>train <- mod1[mod1$rand < 1.7,]
>classify <- mod1[mod1$rand >= 1.7,]
>lda_res <- lda(over_win ~ t1_scrd_a + t1_alwd_a, data=train, CV=TRUE)
That works, and all is well until I try to do a prediction for the holdouts:
2010 Jul 09
1
output without quotes
Hi All,
I am interested in printing column names without quotes and am struggling to
do it properly. The tough part is that I am interested in using these column
names for a function within a function (e.g., lm() within a wrapper
function). Therefore, cat() doesnt seem appropriate and print() is not what
I need. Ideas?
# sample data
mod1 <- rnorm(20, 10, 2)
mod2 <- rnorm(20, 5, 1)
dat
2009 Mar 12
1
zooreg and lmrob problem (bug?)
Hi all and thanks for your time in advance,
I can't figure out why summary.lmrob complains when lmrob is used on a
zooreg object. If the zooreg object is converted to vector before
calling lmrob, no problems appear.
Let me clarify this with an example:
>library(robustbase)
>library(zoo)
>dad<-c(801.4625,527.2062,545.2250,608.2313,633.8875,575.9500,797.0500,706.4188,
2005 Aug 16
1
Defining model classes for enumerations
I have several tables for enumerations. They all have the same content:
id, name, position. I''d like to avoid the tedious work of defining a
class for each one explicitly. Not least, in order to avoid clutter in
the model directory.
Here''s what I''ve come up with:
class EnumRecord < ActiveRecord::Base
def self.define_enums(*enums)
enums.each do |spec|
2012 Mar 10
1
problem with effects : 'subscript out of bounds'
hello. help with effects plots. here's the last bit of code before running the model and then the effects, then the error.
nor.dem <- norway$v162 ## nor.dem is my DV & it is continuous.
nor.dem <- as.numeric(nor.dem)-5
str(nor.dem)
(i had to do a great deal of coding here so i am snipping down to the end)
tmp[which(norway$v128 == "trust completely" & norway$v127
2006 Feb 02
0
proposed bugfix/patch: ActiveRecord cross-module associations
Hi,
I''m still test driving the improved support for module namespaces in
rails and I''ve hit a problem with associations between AR classes in
modules and AR classes in the root namespace.
The long and short of it is I want to be able to say:
Foo::Bar.belongs_to :wibble, :class_name => "::Wibble"
If you don''t try to prefix ''Wibble''
2010 Jun 23
1
Shapefile
Hopefully the attachment will make it this time...
Hi:
I am practicing with the attached shapefile and was wondering
if I can get some help. Haven't used 'rgdal' and 'maptools' much
but it appears to be a great way bring map data into R.
Please take a look at the comments and let me know if I need to
explain better what I am trying to accomplish.
library(rgdal)