similar to: PROPOSAL: Validations as Mixin

Displaying 20 results from an estimated 2000 matches similar to: "PROPOSAL: Validations as Mixin"

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:
2006 May 10
1
model mixin module madness
If I have several models which exhibit the same functionality, it seems makes sense to create a mixin, ''include'' it in each model and save myself some work and repeated code. Where can I define a module which will be available to all models? I can''t seem to find a documented place for them. Alternatively, is there a Rails-standard way of achieving the effect? Ben
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]
2006 Nov 14
11
RESTful mixin, mixin repo?
Hi, I just put together a little mixin to provide pseudo-RESTful services in camping apps. Basically, it looks for a hidden _verb field in form posts, and sets the @method to the supplied value (e.g. put or delete - which browsers don''t support). This lets you define put and delete methods in your controllers. Groovy. Code: http://pastie.caboo.se/22613 Is there any permanent repo of
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 04
11
Query Mixin by Duane Johnson
Hello At the start of October, Duane Johnson announced the Query mixin plugin on this list. The code was attached to the announcement email. Unfortunately, I''ve not been able to locate the attached code. Goggle has not helped me this time. Could somebody forward it to me? Thanks in advance Harvey This e-mail has been scanned for all viruses by MessageLabs.
2006 Mar 26
5
How to write manage created_on and created_by via mixin?
Hi! Definite newbie here - I''m working through this like-hate relationship with Ruby and Rails right now... sometimes things work really well (like blobs seem to rock) but other times, I dunno! :-) Anyway, I''d like put in create and update user timestamps on all my primary domain tables and allow them to be updated automatically by ActiveRecord. Coming from Hibernate, I just
2006 May 17
3
Help mixin in class methods
Starting to feel more confident and code is DRYing up nicely, but I''ve hit a brick wall here and hoping someone can help me. I''ve got a module, TrustRanking, which extends a number of model''s instance methods, and I want to extend their class methods too, but I can seem to work out how to do it. Simply including the module from the class works a treat for the
2007 Apr 30
1
ActiveRecord: removing validations or callbacks on a subclass
Often a parent class has validations (or callbacks or associations) which I don''t want the subclass to have. Is there any simple way to remove these? --~--~---------~--~----~------------~-------~--~----~ 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
2006 Feb 19
1
NOOB: ratings/voting mixin or code example?
so as to not reinvent the wheel, are there any exisiting examples or mixins for a star rating system? basically what i''m looking to do is show pictures of local models which will be voted on by users, and the model with the most votes will get her photo in a calendar. anyone able to point me in the right direction... tutorials, code, whatever would be greatly appreciated! -A --
2005 Nov 28
4
validates_format_of nil
I''ve noticed that validates_format_of will return invalid if the field is nil. Question 1) How should we declare a validation that will validate it with a regex if it is set, but, if the field is not set, just move on Question 2) Why is it done this way? The other validators are only invoked if the field is set . If you want to declare the field mandatory, you add a
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
2007 Apr 13
0
mixin behavior
Hi, all, I need to DRY up some code in a few models. My first inclination, having come from the Java world, was to go with an abstract class. After a bit of reading, I then decided to follow the mixin route instead. Now I''m running into trouble, most likely from a few basic misunderstandings. There are three models I will be using to average and count rating data by executing a
2006 May 19
0
Works in model but not in mixin
Disclaimer: RoR newbie. Using the acts_as_taggable plugin. As an exercise I wanted to switch from the destructive TAG_WITH method to adding tags while preserving the existing ones. On the surface this seemed easy enough and eventually I got it working. However, the following method: def add_tags(list) Tag.transaction do Tag.parse(list).each do |name| if
2006 Apr 18
4
Mixin variables
I''ve created an access control module that I''m including in several different controllers. Everything works fine, but I want to allow each controller to override the default login page with something like this: set_login_pages :secure => ''my_login'' In my module, I''ve set up the set_login_pages method like this: def self.included(base)
2012 Mar 22
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
On Mar 22, 2012, at 12:28 AM, Bill Wendling wrote: > On Mar 20, 2012, at 7:38 PM, Paul J. Lucas wrote: > >> I've read the docs on LLVM exceptions, but I don't see any examples. A little help? > > I don't think this has anything to do with LLVM's IR-level exception system. It sounds to me like you just need a way to handle C++ exceptions inside of the C++ code
2012 Mar 22
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
On Mar 20, 2012, at 7:38 PM, Paul J. Lucas wrote: > To recap, on Mar 14, 2012, I wrote: > >> My project has a C++ library that I want to allow the user to use via some programming language to be JIT'd to call functions in said library. For the sake of simplicity, assume the library has classes like: >> >> class item_iterator { >> public: >> virtual
2012 Mar 21
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
To recap, on Mar 14, 2012, I wrote: > My project has a C++ library that I want to allow the user to use via some programming language to be JIT'd to call functions in said library. For the sake of simplicity, assume the library has classes like: > > class item_iterator { > public: > virtual ~item_iterator(); > virtual bool next( item *result ) = 0; > }; >
2006 Feb 21
11
helper for models?
Is there such a thing? I have some duplicate methods in my models, can I place them somewhere and call them in to my models, thus keeping DRY? -- Posted via http://www.ruby-forum.com/.
2005 May 08
1
"validation" on destroy
I''m building a little application with Rails, and I''m becoming a huge fan of the validations in ActiveRecord. Recently, though I ran into a problem which to me feels like a job for Validations, but I can''t see a way to use them. My model consits of a Trade object, which represents either buying or selling some security. I need to require that at no point has a user