Displaying 15 results from an estimated 15 matches for "subclasses_of".
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
su...
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 &l...
2006 Jul 29
3
Engines question
I would like to get at all models in a rails application to be able to
add a field to every one of them as part of a migration. Something
like the following:
Appmodels.each { |x| add_column x.table_name.to_s, :foo, :text }
I understand I can get the table name using
ActiveRecord::Base#table_name, but how do I get all the models into an
array that I can use in the above manner?
--
Cheers,
Hasan
2011 Jan 14
4
Rails 3 / RSpec 2 use_transactional_fixtures and after_commit
We''re migrating a Rails 2.3.x application to Rails 3 and RSpec 2.x.
In Rails 2.3.x we were using
https://github.com/freelancing-god/after_commit to provide
after_commit functionality (now provided by Rails 3).
The plugin version of after_commit came with some helpers to make
testing with `use_transactional_fixtures = true` work.
From: https://github.com/freelancing-god/after_commit
2007 Mar 21
0
Getting the module name with ObjectSpace...
Hey :)
I''m trying to create a method for making a sitemap dynamically. It
works great for flat sites where you simply have your controllers in
the app/controllers directory. In this case, I can extract the
controller names like,
@controllers
ObjectSpace.subclasses_of(ActionController::Base).each do |obj|
@controllers["#{obj.controller_name}"] = obj
end
However, now I''ve divided the site into modules, that is, I have for
instance both Store::ItemsController and Manage::ItemsController,
which reside in app/controllers/store and app/con...
2006 Apr 07
3
List of all Models
Anyone know a pretty way to get a list of all Models?
That is, a list of all classes which inherit from ActiveRecord:Base
I can''t seem to figure it out!
The best I''ve got is to list the /app/models directory... but, that is
*dirty*.
-hampton.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Apr 24
4
[TIP] Ensure your test data is valid
...sc "Load fixtures into the current environment''s database and display
invalid objects"
task :validate do
Rake::Task[''db:fixtures:load''].invoke
Dir.glob(RAILS_ROOT + ''/app/models/*.rb'').each { |file| require file }
Object.subclasses_of(ActiveRecord::Base).each do |klass|
klass.find(:all).reject(&:valid?).each do |record|
puts "#{record.class}: id=#{record.id}"
p record.errors.full_messages
puts
end rescue nil
end
end
end
end
-------------- next part ---------...
2007 May 31
3
where to get list of all ActiveRecord classes
Anybody know how to get a list of all your model classes from a rails
environment?
I''d like to do something like "ActiveRecord::Base.subclasses" but that
gives me:
pcollins@horatio:~/proj/foobox$ script/console
Loading development environment.
>> ActiveRecord::Base.subclasses
NoMethodError: protected method `subclasses'' called ...
Anybody know how to do
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
2006 May 23
6
How to list all models of an application?!?
How can I get a list of all model classes in the domain of a Rails
application (all models, both in "app/models" and in
components/somedir/model.rb)?
Thanx in advance for your precious help!
Edoardo "Dado" Marcora
2006 Jun 30
6
RSS::Parser Documentation
Hi
I am trying to use the RSS classes from "rss/2.0" and everything works
but I want to know what attributes and properties I can get at from each
of the classes I am getting back.
For example, the class has a "channel" which I can tell has a "title"
attribute (because it works when I query it :) but I would really like a
list of every attribute that is
2005 Dec 27
3
myObject.send(column.name) from Agile Development book
I''m studying the Agile Development with Rails book. In the chapter that
first sets up the depot application (page 68), there is this bit of code
from a view:
<% for product in @products %>
<tr>
<% for column in Product.content_columns %>
<td><%=h product.send(column.name) %></td>
<% end %>
etc...
I am trying to absorb both Ruby and
2006 Apr 27
7
Role Based Authorization recipe implementation?
i got the rails recipes book, i have now an auth system for users
without problems, now i want to made a role based acces for my app, im
following the "Role Based Authorization" recipe of the book but i cant
make it to work even when the tables created and correctly added data
manually definig the roles and rights. als i dont know how to define a
right for use all the actions in a
2007 Sep 13
7
Namespacing Models
Hello everyone,
Do you feel it? The little shiver down your spine when you think of
"namespacing" in rails? To some thats a common feeling, to people like
myself who enforce absolute organization have already thought about
the need for namespaces in rails.
Now I do understand this is an ongoing effort... to some degree.
Controllers and routes, from my experiences work well, that being,
2006 Apr 13
8
DevTower Beta3 Release!
DevTower Beta3! (0.3)
I''m proud to announce some major changes and improvements to DevTower in
this beta release! First and foremost, DevTower is now a full plugin. Also,
DevTower works (only) with Rails 1.1.
==== ABOUT =====
DevTower used to synchronize the development of Ruby On
Rails applications with developers working simultaniously
on multiple systems with Subversion. DevTower