Displaying 20 results from an estimated 6000 matches similar to: "Any good alternative to single-table-inheritance?"
2006 Jul 31
3
Polymorphic associations and single table inheritance
Running into an interesting problem that at first glance appears to be a
bug in the AR association code. However, it''s explicitly coded this way
so I''m not so sure.
I have some code like this:
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class Person < ActiveRecord::Base
has_many :addresses, :as => :addressable,
2006 Jun 14
13
Undefined method
I really hope this is not a bad question (as in he''s abusing the
list). However I could use a little direction (even though I''m
reading books, tutorials)
Right now I''m getting a
undefined method `category'' for 4:Fixnum
The specific lines from the rhtml file are:
<td><%= link_to position.category_id.category, :action => "show", :id
=>
2006 Mar 24
7
Polymorphic associations?
I''ve read the stuff about polymorphic associations here:
http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations
But I''m not sure what exactly they are and what their advantage is. Are
they the same as HABTM, but they''re "two-way"?
Joe
--
Posted via http://www.ruby-forum.com/.
2007 Oct 18
4
Polymorphic Association?
Hi there-
I''m a newbie to this board, RoR, and web development in general. So
please forgive me if this is in the wrong place or if the solution is
really simple...
I''m trying to conceptualize the relationships between a series of
models for a page creation function. What I''d like is to have a
Content Page which consists of a series of Content Blocks. The
Content
2006 Jul 30
3
ActiveRecord - Multiple Address for a single record
I''m trying to figure out the Rails way to model the following problem:
I have 2 tables. One (let''s call it location) contains a single
address. The other (let''s call it company) contains 3 address. I''m
trying to figure out the best way to model this. I''ve created an
address table, a set up the model as follows:
class Address <
2008 Jun 12
1
unidirectional belongs_to polymorphic
The setup:
class Location::Base < ActiveRecord::Base
set_table_name :locations
...
end
class Location::Address < Location::Base
...
end
class Location::Airport < Location::Base
...
end
class Person < ActiveRecord::Base
belongs_to :location, :polymorphic => true, :class_name =>
"Location::Base"
...
end
I want a unidirectional belongs_to relationship. That
2006 Mar 27
1
polymorphism + inheritance
Hi,
currently I do some work with polymorphic associations in egde rails
class Order < ActiveRecord::Base
belongs_to :payment, :polymorphic => true
end
class CreditCardPayment < Payment
end
class PayPalPayment < Payment
end
class Payment < ActiveRecord::Base
has_one :order, :as => :payment
# common stuff in here
end
I want to use [Payment] for common functionality
2009 Aug 07
2
create separate plots by factors
Hello,
I am attempting to create several plots based on "site" (~300 total)
and am having trouble with the code. I simply want to create a plot
using the code, plot(year, peak), for the following dataset. I would
like for each site to be plotted on a separate page and the plots
saved in a directory. Would a "foreach" loop work? I tried a "by"
statement, but
2006 Jul 04
8
inherits_from: Multiple table inheritance
Hey guys,
I just implemented very simple and primitive class table inheritance in
ActiveRecord. The goal is for this to become mature enough to become a
true feature in Rails. Check it out here:
http://guest@blog.raylucke.com/svn/inherits_from
Here?s how it looks in action:
create_table "books", :force => true do |t|
t.column "product_id", :integer
t.column
2006 Jun 09
18
Is IRB the ruby console ?
I''m running script/console but keep getting the message that irb.bat is not
recognized as an internal or external command, operable program or batch
file.
If it means anything I am running instant rails. I can invoke irb straight
forward.
TIA
Stuart
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up
examples of how to have multiple entities in a single-table inheritance
related to anything.
I have an addresses table, but multiple entities can have Addresses:
both Person (which has 2 addresses) and Retailer. I''ve been told that I
need to use single-table inheritance, and this was my attempt:
2006 Apr 04
4
Maintaining and securing the "Perfect Rails/Debian/Lighttpd Stack"
Hi there
I''m planning to build "The Perfect Rails/Debian/Lighttpd Stack",
published by Ezra Zygmuntowicz and Sean Schertell at
http://brainspl.at/rails_stack.html
I''m wondering what sort of constant maintanance that setup would
incur. What actions have be regularly performed to keep this setup
healthy and secure under normal conditions?
Alder
2006 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one
(and other relationship identifiers). I have read the RDoc and the
agile book many times about this and I think i still see it backwards.
Let me outline my app so you have an understanding...
I have 2 tables:
Schools { id, school_name, address_id }
and
Addresses { street1, street2, city, state, zip, country }
*** this
2006 Aug 19
3
Special ruby language for describing sql conditions
I was brainstorming today about a smooth way to define conditions in an
sql query, when the numbers of attributes increase, so does the uglyness.
So instead of passing a hash, I thought you could specify the conditions
directly in code.
I hacked together some example code which actually turned out to work.
The result is concise and pretty beutiful.
def search(params)
Ad.find(:all) do
2006 May 18
7
Ruby Before Rails
As I, like many people, are coming to ruby in the rails era, I''m curious
about how Ruby Web Dev was done prior to rails. Any veterans want to
share their insights?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060518/20cde24d/attachment.html
2006 Jul 22
2
How to SELECT from multiple talbes with AR#find and associations?
So I want to SELECT from multiple tables, so as to be able to do
"SELECT FROM foo, bar WHERE foo.id=bar.id AND bar.baz=23".
How do I do it with AR#find?
Also, I need this for associations. has_many et. al. have :finder_sql,
which is nice, but feels like a Pyrrhic: it''s basically doing the
association in pure SQL, defeating the purpose of AR.
--
-Alder
2006 May 18
4
How do you delete a session variable?
Hi
Let''s say we set session[:foo] = ''bar''. Now we want to remove the :foo
key completely. How do you do that?
Appearantly, session is a CGI::Session [1] instance, so it doesn''t
have #delete like Hash. I tried:
session[:foo] = nil
But then debug(session) shows an empty :foo key. I''d like to remove
that key, as my session is already pretty crowded. Is
2006 Mar 19
2
Multiple polymorphic belongs_to declarations
I have the following models:
class Card < ActiveRecord::Base
belongs_to :deck
belongs_to :front, :polymorphic => true
belongs_to :back, :polymorphic => true
end
class TextContent < ActiveRecord::Base
has_one :card, :as => :front
has_one :card, :as => :back
end
The conflicting has_one declarations don''t work. What I need is
2010 May 25
2
Site Navigation With Polymorphic Has Many Through
Hi, seem to keep running into a wall here. I can''t find any resources on
site navigation that can deal with any model being in the nav, allow
nesting, and can dynamically update.
So I thought about it for a while, and decided on a MenuItems class, which
contained the position of the child in relation to it''s siblings, where the
parent and the child were polymorphic. Then a given
2017 Apr 17
3
Separate AA metadata for load/store portions of memcpy
This is going back to something I had asked on IRC about a few weeks
ago and promised
to get back to when I had some time to actually work on it. For background:
Currently, we can annotate tbaa on memcpy's, but when we do so, the
semantics consider it to apply to *both* the load and the store part
of the memcpy. This is quite a significant limitation and the cause of
a good amount of lost