Displaying 20 results from an estimated 20000 matches similar to: "Models and Modules and subclassing, oh my!"
2009 May 08
3
STI and subclassing twice
I''m trying using STI to implement a hiearchy similar to this:
script/generate scaffold name:string type:string
class Person < ActiveRecord::Base; end
class Customer < Person; end
class Employee < Person; end
class Developer < Employee; end
I.e., there are two levels of inheritance (Developer < Employee <
Person).
When creating a Customer, Rails understands
2006 Aug 17
0
single-table inheritance and select
I''m getting some weirdness trying to use a select widget to choose
the type from a collection of three objects sharing a database table
via single-table inheritance (STI). I''d be grateful for any advice on
whether it''s a bug or a feature, if a feature why and how I can more
easily do what I''m trying to do.
So I have the usual STI setup, with a
2006 Jun 12
0
JobsOnRails and Yet Another Portal
I just launched two Rails projects that I''ve been sitting on for a
while.
The first is JobsOnRails.com, which I announced here back in March.
After the 37''s created their nifty job board I decided to shelve mine,
but have launched it anyway because it was just about finished.
There isn''t much on it right now, but it''s free and has a fun domain, so
if
2006 Jan 19
3
Why does Object.subclasses_of ignore subclasses within modules?
ActiveSupport provides a method Object.subclasses_of, shown below:
def subclasses_of(*superclasses)
subclasses = []
ObjectSpace.each_object(Class) do |k|
next if (k.ancestors & superclasses).empty? ||
superclasses.include?(k) || k.to_s.include?("::") ||
subclasses.include?(k)
subclasses << k
end
subclasses
end
Can anyone shine some light on why
2005 May 31
1
AJAX & Partials
Hi,
looking to see if I''m on the right track here...
we''re selling widgets to customers, but there are a number of different
type of widgets and each different type of widget has a number of
parameters that the customer can specify, in effect each customer orders
widget''s customised in ways particular to that specific order.
We use STI to store each different widget
2006 Jan 08
1
Subclassing only a specific portion?
Hi,
I''m sure there is an easy way to do this, but I just can''t see it:
I have a large amount of rooms, that are for different purposes, and
for only one ''purpose'' do I want to create a specific subclass. Ex:
banquet,wedding,admin. I want to have additional information about
admin rooms.
Trying to use the ''type'' field just gives an error
2006 Nov 05
4
Why Struts2 use dojo instead of Scriptaculous?
Hi,
I''m using prototype/Scriptaculous in my open source project JSControlsTags
http://jscontrolstags.sourceforge.net/
I''m Struts user and in the new version Struts2, the framework integrate AJAX
with dojo
and not with Prototype/Scriptaculous. I asked in the Struts forum, why
Struts2 integrate
by default dojo and not scriptaculous.
Here Struts answer :
------------------------
2006 Jan 02
0
Best practice for registering/discovering STI subclasses?
Folks,
I''m fairly new to Rails, and I''ve Googled around for an answer to this
question with no luck...
Consider a little blog application that has uses single-table
inheritance for the handful of different content types via a Content
base class and subclasses like FooContent and BarContent. That part
all works well for me.
Now consider the view that presents actions to the
2016 Nov 01
2
Ambiguity in !tbaa metadata?
I was trying to add some stronger assertions in the verifier around
!tbaa metadata when I ran into an ambiguity: I think the encoding of
the metadata nodes are such that a given node can be interpreted as
either a struct type node or a scalar tbaa node. I'd like a sanity
check before I try to fix or work around this.
Consider some IR that I got from running clang over a small C++
program:
2006 Jan 18
0
subclasses_of - why does it ignore subclasses within modules?
ActiveSupport provides a method Object.subclasses_of, to give the
subclasses of a given class. However, it ignores any subclass within
a module, so :
class A
end
class B < A
end
Object.subclasses_of(A) # returns [B]
module C
class D < A
end
end
Object.subclasses_of(A) # returns [B], even though C::D is also a subclass of A
class E < C::D
end
Object.subclasses_of(A) # returns
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 Apr 29
0
[991] branches/wxruby2/wxwidgets_282/doc/textile: Update documentation for painting methods and WindowDC subclasses
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding:
2007 Nov 09
0
iframe is reloading during each sortable drag/drop point
We are creating a simple widget portal for our site and trying to use
Sortables. Each of our widgets is an iframe. But when you try to
drag an element containing an iframe the Sortables api causes the
iframe to reload at each possible drop point. This causes the ui to
shutter and become unusable.
I have narrowed the issue down the onEmptyHover where
dropon.insertBefore is called. Is there a
2011 Apr 22
0
how to set up fields_for to choose a subclass?
I have an STI model where UtilityProvider is the parent class, and
there''s a sub-class for each specific utility provider.
When the user goes to choose a UtilityProvider, I want to present a
pull-down list of UtilityProvider.subclasses (or, more likely, a
filtered version of that), and when the user hits [submit] to create the
appropriate subclass.
To add a little spice to the question,
2007 Mar 28
4
Disabling ActiveRecord "type" column subclassing
Hi! I have a legacy table that has a column named "type" and need to
remove this automatic subclassing by ActiveRecord. The api pages are
vague about this, and I tried
self.inheritance_column = "xtype"
which seemed to get me half-way. In the validate_on_create method, the
value of self.type was my model Class name.
How would you disable this feature?
--
Posted via
2014 Mar 27
2
[LLVMdev] [lld] Subclassing LayoutPass
Hi,
I think it would be great if we could subclass the LayoutPass.
All the generic functionality could be in the parent to run the
layout-after/in-group/ and currently the layout-before passes(until it
gets removed).
Flavors can *choose to run the layout passes* that they use and
determine the way things get ordered in the layout pass.
The compare function in the LayoutPass would call
2010 Aug 19
4
Subclassing a model
Is it possible to define a subclass for a model, that defines additional
data columns, which are stored in a separate table?
Is there any description, how to do this?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2008 Dec 09
7
subclassing vs mixins, which one should be used?
Hey all,
I have two models in my rails project that share a lot of traits. They
each have the same 4 properties, and now I need to add 2-3 methods to
each one that will be the same. In the spirit of DRY I am looking for
a solution to write these methods only once.
Both of these models already inherit from ActiveRecord . . . and I
didn''t know if it was safe to just "whip up" a
2006 Aug 15
6
Theoretical: Should models be subclasses of AR or mix it in?
All,
My apologies if this is a little long-winded and stream of
consciousness-y :).
SUMMARY: Why do we extend ActiveRecord instead of mixing it in to our
model classes?
Been thinking about my app''s models and starting to want to build
something of a hierarchy. I have some commonality across 3 of my model
classes and I''d liek to aggregate the behavior in a superclass.
2006 Sep 25
3
Subclasses - help required
Hello all and hoping for some insight
a project manger type of application, staff are assigned to projects,
but each staff has varied roles for different projects... STI does not
seem to be applicable here
Imagine a table staffs...
id int
name varchar
blah....
is_manager int 1
is_engineer int 1
is_producer int 1
and projects...
id
name
manager_id
engineer_id
producer_id
how is the best way