Displaying 20 results from an estimated 10000 matches similar to: "Using ActiveRecord With (Previously) Derived Classes"
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.
2009 Feb 02
2
ActiveRecord::AssociationTypeMismatch (User(#54754560) expected, got User(#54510280))
i keep getting this AssociationTypeMismatch error. i think this could
be a bug related to ruby/rails when using mixins. heres a short
version of my code:
# user.rb
require ''friend_invitation''
require ''friendship''
class User < ActiveRecord::Base
include FriendInvitationUser, FriendshipUser
...
end
# friendship.rb
...
module FriendshipUser
def
2008 Sep 05
1
Derived classes
Coming from a C++ and C# background I would like to know how inheritance works with 'R'. The classical example is I can define an abstract class 'Shape' and have an array of 'Shape's but each instance could be a Circle, Square, Triangle, etc. because they all derive from 'Shape'. At runtime if I wish I can tell the type of the 'Shape' using various language
2007 Apr 24
2
remote database ActiveRecord model
Does anyone know how to make a model connect to a remote database and
only for that specific model?
That way I can do the typical CRUD functions on a remote server?
--
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,
2006 Aug 14
1
Testing CRUD/Rest Controllers
I have a few simple controllers doing plain, simple crud in a standard way.
now it''s not very DRY to write a funtcional test for each controller, since
they are all doing the same (apart from a few variable names, but that could
be easily inflected or so).
is there a way to do this?
e.g. does inheritance work with tests, so i define a base test first,
inherit my other tests and add a few
2007 Oct 08
0
Using mocks in classes
I am mocking a rails model that hasn''t been implemented and belongs_to a
model that I am developing with rspec.
The model in development, Audit, has_many AuditItems which is being mocked.
When created, Audit creates the first instance of AuditItem.
To enable me to mock AuditItem I have created a factory method in Audit to
create the AuditItem, rather than creating it in the initialize
2007 Mar 24
1
spec''ing metaprograming & rails CRUD
For edge rails there is a Crud generator. There is also a CRUD
controller that is out there from which you can inherit your other
controllers (see http://geekonomics.blogspot.com/2006/07/crud-and-
shared-controllers.html)
This got me thinking about Crud controllers in general. As far as I
know, the generator can''t produce crud classes which are nested
(i.e.
2006 Aug 03
5
DRYing up the view
Hello everyone!
I have generic views for CRUD operations
For example I render(''shared/list'') from controller
shared/list.rhtml
...
<% for item in @list %>
<tr class="<%= cycle ''list-line-odd'', ''list-line-even'' %>">
<%= render :partial => ''item'', :locals => { :item => item } %>
2011 Sep 23
3
ldap ENC extension to use environment parent node
Hi,
We currently use ldap ENC to set server role variables and extlookup
to set domain or environment variables.
I have a suggestion regarding ldap use as an ENC - if a node within
ldap has the environment attribute set then it should inherit/mixin
(if available) from a node named after it''s environment.
It could be populated with only puppetVar type attributes so that any
environment
2007 Nov 01
8
Specifying mixins
Hi folks,
Can anyone share some accumulated wisdom about the best way to spec
mixins in general, and (Jamis Buck-style) ActiveRecord "concerns" in
particular?
The standard situation here is that there''s a bunch of functionality,
related by concept if not by implementation, that one wants to inherit
in many different classes (e.g. ActiveRecord models) without having to
2006 Jan 23
3
prototype.js: enumerable mixin for hash broken
Hello everyone.
I am not sure if this is the right place to post, please redirect me
if there is a mailinglist more specifically dealing with prototype.js.
After playing around with the very inspiring prototype library I have
found a rather annoying thing, that makes the usefulness of the
Enumerable mixin for Hashes
questionable, if I am not totally wrong (again :-).
Here an example:
2007 Mar 24
0
Using spec fixtures with integration tests
Hi all,
How can I use spec fixtures with rails integration tests ?
I''ve tried adding {{ fixtures "../../spec/fixtures/myfixture" }}
to the integration test but the fixtures are not loaded when I run the
rake task.
Rails doesn''t load symlinked fixtures either so I copied the files from
spec/fixtures for the time being. Not very DRY.
Any ideas ?
Keith
2008 Nov 22
1
Testing Environment for Plugints
Hello,
I''m currently creating my first plugin in rails. It creates a model
and a mixin for controllers. For testing purposes I need a test
controller (sort of a mock) to which I can include my mixin and test
wether the mixed in methods work. My problem is in order to do this I
either have to setup my test enviorment in a rails app outside of my
plugin or I have to replicate a whole rails
2006 Sep 12
1
acts_as_taggable -- which one?
There appear to be three acts_as_taggable implementations and I''m looking for
a recommendation on which to use.
- Gem
- DHH plugin
- Dema mixin
The Gem implementation appears to be obsolescent, from what I can read on
the lists and Google search.
I like that the DHH plugin uses polymorphic associations because there will
be lots of different taggable items in my application; however,
2006 Nov 04
0
How do CRUD and REST work for a wizard-style application?
I''m rewriting an application with the intention to use the elegant
CRUD and REST design principles as outlined by DHH in his RailsConf
Keynote[1].
The question is: how do you use those principles for an application
that is of a sequential nature?
The application works much like an MS Windows wizard: user begins at
screen foo. After doing (or not) some stuff in screen foo, he is taken
to
2006 Aug 18
0
Impact of inheriting controllers on models
I have some protected methods and authentication/acl filters I want to
inherit down through my controllers.
So I have controllers which inherit like this:
Application_controller
\
-- AdminArea Controller
--\
----dashboard controller
----user controller
----content controller
----\
------page controller
------placement controller
-- PublicArea Controller
--\
........
At the deepest level the
2010 Apr 06
2
respecting original matrix dimensions
Hi All,
I'm hoping someone else can help me out with this. I am doing some
matrix algebra using sub-parts of matrices, and sometimes I need only
a single row/column of the original matrix. However, whenever I pull
out only a single row/column, R returns a row vector, but often this
will break my matrix algebra. Is there any *easy* way to get R to
remember what the single row/column came out
2020 Jul 11
2
[RFC] Introducing classes for the codegen driven by new pass manager
(NPM: new pass manager; LPM: legacy pass manager)
Hello, community
While we're still working towards using NPM for optimizer pipeline by default, we still don't have a machine pass interface and the corresponding machine pass manager using NPM. The potential benefits using NPM aside, this inhibits us from making any progress on deprecating LPM for the codegen pipeline which blocks
2007 Feb 20
8
overriding included classes
I believe this has already been discussed[1], but I''d like to add a bit
more to that original discussion and see if anyone has any suggestions.
Here''s what I''m trying to do: we have a set of very thorough "wipe"
scripts that run every night on our workstations. I''d like to stash
these into a class so that I can include them as a group:
class wiped
2006 Feb 22
5
Auditing mixin for model classes. Small problem
I want to include common auditing functionality in my models. This
involves storing the changes made to a model in a seperate table :
I have created the functions in an Audit module :
module Audit
before_update :before_changes
after_update :after_changes
def before_changes
old=self.class.find(id).attributes
@changes=[]
attributes.each do |key, val|
if val != old[key]