Displaying 20 results from an estimated 27 matches for "base_class".
2011 Apr 05
1
Why does AR use base_class for polymorphic relationship "type"
I have a couple models that inherit from a base class that then
inherits from AR.
When they are used in a polymorphic relationship the "type" is always
the base class.
Just curious if anyone has a reason why it doesn''t use the *actual*
class rather then the base_class. I have patched AR to use the actual
class if !base_class.table_exists? but it adds another query each time
(which in turn fails some of the rails tests).
My only guess was for use with STI, but even then I am not sure if
there is a better solution then using the base_class
-Eric
--
You receiv...
2006 Mar 20
3
help: acts_as_versioned setup error "undefined local variable or method ''base_class''"
..."acts_as_versioned" label to the model file
- generated a migration file
- added the table creation code and the command "Post.create_versioned_table"
to the migration file
- ran "rake migrate"
What I got is the error "undefined local variable or method ''base_class'' for
Post:Class". I tried with other models and kept getting the same error. It
seems like "rake migrate" is missing the right environment setup, and thus
can''t find the Post class defined in the model file. Is there some step
I''ve overlooked?
Thanks a...
2006 Jul 31
3
Polymorphic associations and single table inheritance
...::AssociationProxy#set_belongs_to_association_for
and ActiveRecord::Associations:: HasManyAssociation#construct_sql it''s
clear why.
>From
ActiveRecord::Associations::AssociationProxy#set_belongs_to_association_for:
record["#{@reflection.options[:as]}_type"] =
@owner.class.base_class.name.to_s
Removing the call to base_class results in the behavior I expected. I
did this by patching the two classes at runtime from a file in lib/.
I guess my question is, are my expectations wrong here or is this a bug?
The inclusion of base_class strikes me as something someone meant to do....
2007 Nov 20
2
Plugin: create instance methods dynamically in ClassMethods?
Hi all
I have the following plugin code:
module IncenseCrud
def self.included(base_class)
base_class.extend(ClassMethods)
end
module ClassMethods
def performs_incense_crud
def index
list
return render(:action => ''list'')
end
end
end
end
In init.rb I have the following:
require File.dirname(__FILE__) + ''/lib/i...
2006 Mar 28
12
cached-model broken with Rails 1.1
It looks like cached-model is broken again under rails 1.1. Can anyone
confirm? Note that the exception below indicates it''s trying to treat
CachedModel as the class name of the model, rather than using the proper
class name (which is Entry in this case, and the table called entries).
This is a model using Single Table Inheritance and acts_as_tree, and
worked just fine under 1.0 and
2011 May 23
0
Fallback for partial_paths on rendering process
...Place < ActiveRecord::Base
class City < Place
lets say I have a City on the @place
whenever I try using the
render @place
I will get an error, saying the templace cities/city doesn''t exist
but I do have a places/place template.
Is the any nice way to add this fallback for the base_class on these
cases?
Also in search, I have collections with several types of items
so I''d have to manually render each item using class.base_class.name
to force using place instead of city
when rendering the item
Is that the best/only solution?
Thanks
--
You received this message because...
2011 Oct 06
4
[LLVMdev] TableGen and Greenspun
...specific defm and all of the classes
> it inherits from.
So here's why I think the for loop proposal can't be a preprocessing
phase. Down in the guts of this I fundamentally need to be able to do
this:
multiclass blah<list<int> Values> {
for v = Values {
def DEF#v : base_class<v>;
}
}
Will that work? Is the for loop evaluated after parameter binding?
I like the for loop idea. But it can't be "just" a preprocessing step.
Also, I know I introduced the #..# "pasting" operation but I've found it
to be too limiting. In this example:...
2006 Jul 15
2
FieldQuery not returning anything
...s is not working the way i thought it
should be, what am i doing wrong? Here''s an example ..
I''m storing model data in the index like this:
doc << Field.new( "object_id", object.id, Field::Store::YES)
doc << Field.new( "type", object.class.base_class.to_s,
Field::Store::YES)
This is working fine, i get something like this:
>> i[0]
=> Document {
stored/uncompressed,indexed,<object_id:3>
stored/uncompressed,indexed,<type:Category>
}
Now I want to search for all documents, with a specific type.. here''s my
na...
2011 Oct 06
1
[LLVMdev] TableGen For Loops
...(David A. Greene) writes:
> So here's why I think the for loop proposal can't be a preprocessing
> phase. Down in the guts of this I fundamentally need to be able to do
> this:
>
> multiclass blah<list<int> Values> {
> for v = Values {
> def DEF#v : base_class<v>;
> }
> }
>
> Will that work? Is the for loop evaluated after parameter binding?
I think I can actually make this work using the existing multidef
feature code. The ideas are fundamentally the same. I do like the
for syntax a lot better.
Che-Liang, would you mind if I pla...
2007 Jun 04
1
acts_as_rateable in Beast
...and I''ve added
this method to my controller:
def vote_up
return unless logged_in?
rateable = @rateable_class.find(params[:id])
# Delete the old ratings for current user
Rating.delete_all(["rateable_type = ? AND rateable_id = ? AND
user_id = ?", @rateable_class.base_class.to_s, params[:id],
@current_user.id])
rateable.add_rating Rating.new(:rating => 1, :user_id =>
@current_user.id)
end
Is there a way to dynamically update (ajax) the rating in my view
without having to refresh the page? I''ve tried link_to_remote and am
loading javascript file...
2006 Dec 28
2
STI, controllers and views
Hello,
I have set up that uses single table inheritance. I have a number of
model subclasses following the example in AWDWR that uses Manager <
Employee < Person.
First question. Do I need to create controller classes for each? I
don''t think I do because a single controller should be able to shunt the
data between the models and the views.
Second question. Say I have a view
2016 Mar 26
2
DW_TAG_member extends beyond the bounds error on Linux
...anager *) tm = 0x00007fd133cfb570
I suspect each one may be different root cause. I was able to capture one
callstack of a small repro:
Breakpoint 1, DWARFASTParserClang::ParseChildMembers (this=0x8c4520,
sc=..., parent_die=..., class_clang_type=...,
class_language=lldb::eLanguageTypeUnknown,
base_classes=..., member_accessibilities=..., member_function_dies=...,
delayed_properties=...,
default_accessibility=@0x7ffdf3888cac: lldb::eAccessPublic,
is_a_class=@0x7ffdf3888cab: false, layout_info=...)
at
/home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/source/Plugins/SymbolFile/DW...
2016 Mar 27
0
DW_TAG_member extends beyond the bounds error on Linux
...> I suspect each one may be different root cause. I was able to capture one
> callstack of a small repro:
>
> Breakpoint 1, DWARFASTParserClang::ParseChildMembers (this=0x8c4520,
> sc=..., parent_die=..., class_clang_type=...,
> class_language=lldb::eLanguageTypeUnknown,
> base_classes=..., member_accessibilities=...,
> member_function_dies=..., delayed_properties=...,
> default_accessibility=@0x7ffdf3888cac: lldb::eAccessPublic,
> is_a_class=@0x7ffdf3888cab: false, layout_info=...)
> at
> /home/engshare/third-party2/lldb/3.8.0.rc3/src/llvm/tools/lldb/sou...
2016 Mar 27
1
DW_TAG_member extends beyond the bounds error on Linux
...may be different root cause. I was able to capture one
>> callstack of a small repro:
>>
>> Breakpoint 1, DWARFASTParserClang::ParseChildMembers (this=0x8c4520,
>> sc=..., parent_die=..., class_clang_type=...,
>> class_language=lldb::eLanguageTypeUnknown,
>> base_classes=..., member_accessibilities=...,
>> member_function_dies=..., delayed_properties=...,
>> default_accessibility=@0x7ffdf3888cac: lldb::eAccessPublic,
>> is_a_class=@0x7ffdf3888cab: false, layout_info=...)
>> at
>> /home/engshare/third-party2/lldb/3.8.0.rc3/src...
2011 Oct 06
0
[LLVMdev] TableGen For Loops
...>> So here's why I think the for loop proposal can't be a preprocessing
>> phase. Down in the guts of this I fundamentally need to be able to do
>> this:
>>
>> multiclass blah<list<int> Values> {
>> for v = Values {
>> def DEF#v : base_class<v>;
>> }
>> }
>>
>> Will that work? Is the for loop evaluated after parameter binding?
>
> I think I can actually make this work using the existing multidef
> feature code. The ideas are fundamentally the same. I do like the
> for syntax a lot better....
2008 Apr 11
1
polymorphic associations wrong when used with inherited class?
Consider the following:
class Event
belongs_to :event_object, :polymorphic => true
end
class Asset < ActiveRecord::Base
end
class EventedAsset < Asset
has_one :event, :as => :event_object
end
EventedAsset.find(:first).event generates the following SQL:
SELECT * FROM `events` WHERE (events.event_object_id = 1 AND
events.event_object_type = ''Asset'') LIMIT 1
2008 Sep 25
1
defining polymorphic type condition
...when @reflection.options[:as]
@finder_sql =
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id
= #{@owner.quoted_id} AND " +
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type
= #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
else
@finder_sql =
"#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} =
#{@owner.quoted_id}"
end
@finder_sql << " AND (#{conditions})" if conditions
end
This cannot easily be changed. The type condit...
2012 Mar 22
1
why doesn't .where() honor polymorphism?
...For example:
class MyModel < ActiveRecord::Base
belongs_to :parent, :polymorphic => true
end
I would expect:
MyModel.where(:parent => a)
to be equivalent to:
MyModel.where("my_models.parent_id = ? AND my_models.parent_type = ?",
a.id, a.class.base_class.name)
Is there a philosophical reason it doesn''t make this transformation?
- ff
P.S.: After writing this, I realize it''s not just for polymorphism. I
would expect the NON-polymorphic case to transform:
MyModel.where(:parent => a)
into
MyModel.where("my_models.pa...
2016 Mar 27
0
DW_TAG_member extends beyond the bounds error on Linux
...ause. I was able to capture
>>> one callstack of a small repro:
>>>
>>> Breakpoint 1, DWARFASTParserClang::ParseChildMembers (this=0x8c4520,
>>> sc=..., parent_die=..., class_clang_type=...,
>>> class_language=lldb::eLanguageTypeUnknown,
>>> base_classes=..., member_accessibilities=...,
>>> member_function_dies=..., delayed_properties=...,
>>> default_accessibility=@0x7ffdf3888cac: lldb::eAccessPublic,
>>> is_a_class=@0x7ffdf3888cab: false, layout_info=...)
>>> at
>>> /home/engshare/third-party...
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde