Displaying 20 results from an estimated 6000 matches similar to: "AR: column methods?"
2006 Mar 17
2
Controller/View Organization (Newbie Question)
Good afternoon all...
First, let me apologize for asking a potentially dumb question. I''m
new to both Ruby and Rails, but I do have a long background in OO
programming and web development.
My question is about how to structure controllers for the various
models which I will need in my application. My data will look
something like this:
Dog
- (has_many) TrainingSessions
-
2006 Feb 06
4
Relationship Question (STI)
My girlfriend and I have been dating for two years, and she just told me she
has an STI...
Actually, I currently have three different models, like: Dog, Whale, Monkey
They all have some similar attributes, but, they are unique enough to
break into their own models. I could use STI, but I think the table would
just have too many columns.
Now, I wanted to let the Dog''s, Whale''s
2006 Feb 19
0
creating a model that has other models as elements
Say I have the following three tables:
dogs
-------
id (PK)
name
cats
------
id (PK)
name
recipies
-----------
id (PK)
recipie_text
I''ve made a model for each of them: Dog, Cat and Recipie.
Now I want to create a model, Cookoff, that will contain arrays of
Dog, Cat and Recipie objects. There is no associated database table
for Cookoff because it''s merely a container for a
2009 Sep 23
5
Overriding AR read/write_attribute - Overridden write_attribute Is Never Called
Could someone explain this?
#config/initializers/ar_attributes.rb
module ActiveRecord
module AttributeMethods
alias_method :ar_read_attribute, :read_attribute
def read_attribute(attr_name)
p "read_override"
ar_read_attribute(attr_name)
end
alias_method :ar_write_attribute, :write_attribute
def write_attribute(attr_name, value)
2006 Feb 01
7
Explanation of "alias_method"
Hi!
I''m trying to extend ActiveRecord''s find method (Rails 1.0, Ruby 1.8.2),
but I recognize a strange behaviour of the "alias_method" call.
I wrote a very simple script to explain my problem:
------------------------------------------------------
module ActiveRecordExtension
def self.included(base)
base.extend(ClassMethods)
base.class_eval do
2006 Feb 22
15
Fixtures and Relationships
In my daily development, I migrate back and forth between versions, and
often do: rake load_fixtures...
... in order to populate my development database with fun data.
Now, with any HABTM relationship, there are failures, as there is no way to
say "which" fixtures to load first.
Within an actual functional or unit test case, you could simply load them in
the proper order, but
2006 Mar 12
1
alias_method interferes ApplicationHelper
Hello,
I''m using Ruby 1.8.4 (darwinport), rails-1.0.0 (gem) , Powerbook / Mac
OS X 10.4.5 , Webrick.
How come Rails always raises NoMethodError for my helper (must_fill and
rp or number_to_currency_rp) in application_helper.rb ?
I doubt that alias_method is the culprit, but if i give #
comment then there will be no errors at all ... :/
what am i doing wrong? is it a bug or stupid me? Thx
2006 Mar 12
1
a better way to alias methods
Hi is there a better way to accomplish this task?
class PortfolioController < ProjectController
layout ''portfolio''
def boing
redirect_to :action=>:index
end
alias_method :new , :boing
alias_method :destroy , :boing
alias_method :edit , :boing
alias_method :update , :boing
end
My portfolio controller implements view only
2008 Jan 18
2
NameError when using alias_method -- but method exists?
Hello Rubyists,
I am a bit stumped here. I want to extend the ''load_file'' method in the
YAML module. Following along with the PickAxe example of making old
methods do new things, I try this in irb:
>> module YAML
>> alias_method :orig_load_f, :load_file
>> def load_file(*args)
>> contents = orig_load_f(*args)
>>
2006 Jan 11
5
stack level too deep problem
Hi all, I''m trying to overload the link_to function, (to disable link_to if
the user has no access right)
this is my code, it work the first time I run the application, the second
time I refresh the page I always get "stack level too deep error"
module UsersHelper
include ActionView::Helpers::UrlHelper
alias_method :link_to_original, :link_to
def permission?
true
2007 Feb 26
2
undefined method ... from `alias_method'
0 wicked var/www % ./script/console
Loading development environment.
>> r = Recipe.find :first
NameError: undefined method `recipe_type='' for class `Recipe''
from ./script/../config/../config/../app/models/recipe.rb:
101:in `alias_method''
In recipes_controller:
alias_method :orig_recipe_type=, :recipe_type=
def recipe_type=(t)
if t.nil?
2012 Mar 28
1
parallel bash scripts
Check out the redirection at the end of each command. 1>&2 redirects
the standard out of your child command to the standard error which then
appears in the parent shell. At the end the last & launches your
command into a background shell and then moves on to launch the next
command. The redirections don't care if the command ever terminates.
The result is that both commands
2012 Nov 24
2
Building factors across two columns, is this possible?
I am trying to make it so two columns with similar data use the same internal numbers for same factors, here is the example:
> read.csv("test.csv",header =FALSE,sep=",")
V1 V2 V3
1 sun moon stars
2 stars moon sun
3 cat dog catdog
4 dog moon sun
5 bird plane superman
6 1000 dog 2000
> data <-
2006 Oct 10
5
oddness when adding to index -
I was having some odd results when working with acts_as_ferret (current
trunk), so I decided to test with the current version of ferret to see
if I encountered the same problem. I did. Here are the details:
installed ferret 0.10.10 on debian sarge with ''sudo gem install ferret''
(btw, same results on OSX)
opened up an irb session:
irb(main):001:0> require
2008 Jul 24
2
factor question
Hi!
Suppose I have a factor:
> fac1 <- factor(rep(c("dog","cat","tree"),c(2,3,4)))
> fac1
[1] dog dog cat cat cat tree tree tree tree
Levels: cat dog tree
> length(fac1)
[1] 9
Now I want to get rid of the dogs:
> fac1 <- fac1[3:9]
> fac1
[1] cat cat cat tree tree tree tree
Levels: cat dog tree
>
How should I remove the dog from the
2000 Oct 12
2
getting a windows environment variable in r
hi-
I would like to get a value set with the dos set command (e.g. set dog=cow) in a rterm session on rterm 1011 under windows 2000. if I try in a dos window:
set dog=cow
echo %dog%
i get cow (what I want)
then i start rterm
system("echo %dog%",intern=T)
gives "%dog%"
I can of course do something like
set dog=cow
echo %dog% >jnk.rin
and then start rterm and
2006 Apr 25
1
lme: how to compare random effects in two subsets of data
Dear R-gurus,
I have an interpretation problem regarding lme models.
I am currently working on dog locomotion, particularly on some variation
factors.
I try to figure out which limb out of 2 generated more dispersed data.
I record a value called Peak, around 20 times for each limb with a record.
I repeat the records during a single day, and on several days.
I tried to build two models, one
2010 Jan 15
1
Chaining queries in ActiveRecord
Hi all,
Stuck at this problem for several days. Tried to use named_scope,
scope_out, and plugin such as searchlogic, but no result.
The problem is as follows: I have a pic table and tag table, and a
join table called pic_tag (with only pic_id and tag_id) so that I can
associate N pics to M tags. This is the tutorial way to set up a many-
to-many association. I''m trying to implement a
2005 Sep 27
1
Moaning dog...
Here's one for you phone people....
An elderly lady phoned her telephone company to report that her telephone
failed to ring when her friends called - and that on the few occasions when it
did ring, her pet dog always moaned right before the phone rang.
The telephone repairman proceeded to the scene, curious to see this psychic
dog or senile elderly lady. He climbed a nearby telephone pole,
2010 Mar 31
2
interpretation of p values for highly correlated logistic analysis
Dear list,
I want to perform a logistic regression analysis with multiple
categorical predictors (i.e., a logit) on some data where there is a
very definite relationship between one predicator and the
response/independent variable. The problem I have is that in such a
case the p value goes very high (while I as a naive newbie would
expect it to crash towards 0).
I'll illustrate my problem