search for: mixin

Displaying 20 results from an estimated 197 matches for "mixin".

Did you mean: mixing
2006 Jan 23
3
prototype.js: enumerable mixin for hash broken
...ryone. 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: var a = $H({a:1, b:2, c:1, d:3}); document.writeln(a.inspect().escapeHTML()); // yields: #<Hash:{''a'': 1, ''b'': 2, ''c'': 1, ''d'': 3}> var b...
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) with...
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 Jan 15
6
PROPOSAL: Validations as Mixin
...I caught only three depenedencies: 1. validates_numericy --> depends on ActiveRecords'' before_type_case 2. The exceptions were from the ActiveRecord namespace 3. Including Validations hooked on methods like save It would seem to me that Validations would be best off as an independent mixin. All ActiveRecord would need to do is mix it, add validates_numericay (1), catch the exceptions and rethrow them as ActiveRecord exceptions (2), and hook save type methods (3). What does everyone say? Would this be a good change? Is there an important reason for *not* doing this? -- Posted...
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 self.included(includ...
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 greatl...
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: h...
2007 Feb 08
0
derive.js - Ruby-esque derivation/mixins for Prototype
...some modeling issues I was having on a large JS project. I know there have been serveral alternative "write JS in Ruby" type efforts, including ruby.js, rb2js, and prototype.js itself, but I was hoping to keep it as light as possible while gaining the most powerful aspects of derivation/mixins/callbacks. Much like the prototype library, I''d like it to have an air of Ruby without trying to twist a language I actually like (JS) into something it''s not. It''s cleaned up a lot of the project I was working on, but I''m sure there may be some additional comp...
2008 Dec 09
7
subclassing vs mixins, which one should be used?
...these models already inherit from ActiveRecord . . . and I didn''t know if it was safe to just "whip up" a super class for them both and have them inherit the methods from that(competent at rails and ruby, but grasping for that intermediate level here). I know that Enumerable is a mixin that is included in arrays and hashes, etc and that I can create modules. (where should I put them in rails?). Does anyone have any good information on subclassing in rails vs mixins? Tutorials, good write ups or books to help me understand further? Even your own advice would be great. Thanks ahea...
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 scheduled job. Basically, I want to get averages and counts for the last week, the last month, and all time...
2006 Nov 14
3
[UHH] any blogs sprung from camping?
...ent and server for Camping. -- I was wondering if anyone had gone down the OpenID client/server route? I''m in the process of writing one myself as a demonstration of camping for my local ruby group. I''m in the process of writing the server, and I think I can supply the client as a mixin. If anyone has done work on this front, I''d be interested to combine efforts. I too see many opportunities for tiny little gnat sized apps working together in glorious harmony. And user auth is certainly the first step. Cheers, -Mark
2006 May 11
1
Mixins
If I want to write a function which will be available to views, I write a helper function in one of the places set aside or that very task by Rails. If I want to write a little suite of functions to be mixed in by a number of model classes (but not all), where do I put them? Plug-ins look like AN answer, but they also seem a little heavyweight for simple, project-specific tasks.
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
2007 May 01
2
Using mixins versus delegation
...o I broke much of the code out into separate classes that I delegate to. ActionController::Base already has 160 or so instance methods and I''m not sure adding even more is a good idea, or is this not an issue? It seems the convention in Rails core and for plugins is to add functionality by mixing in modules into core classes that are already quite big. Can anybody on the list give any guidance or examples as to when using delegation is better than mixing in modules? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Gr...
2005 Nov 06
1
mixins not reloaded as expected?!
Hi guys, in development mode a module mixed into a helper class seems not to be reloaded inside app/helpers: class TestHelper include EvenMoreHelp #foo end module EvenMoreHelp # bar end the contents of #foo get refreshed, but not #bar... is there a way to fix that behaviour. I intend a full reload in development mode for obvious reasons. Regards Peter
2006 Sep 05
0
Reloading dependencies in Edge Rails?
I''m developing a library called Hark. The structure is: lib/ hark/ session.rb mixins.rb hark.rb hark.rb: ==== module Hark include Hark::Mixins ... end application.rb: ==== class ApplicationController < ActionController::Base include Hark end my_controller.rb: ==== def login hs = session[:hark_session] = Hark::Session.new ... end So application.rb bring...
2006 Apr 11
1
Mixins?
As is often the case when I tackle a new platform/language, I get the big picture very quickly (because frameworks are frameworks are frameworks) but its the nitty-gritty of the language that bogs me down... So I have some similar methods on a few of my model classes that I wanted to push into a helper. Now I reckoned that the Ruby way was to create a module and mix it in with include. However, I
2005 Sep 03
13
acts_as_taggable v2 - Tagging on Steroids
Hi folks, Thanks to the community feedback on the 1st version, I''ve come up with a much improved version of the acts_as_taggable mixin. ThereĀ“s some piece of the action here: http://dema.ruby.com.br/articles/2005/09/03/tagging-on-steroids-with-rails Cheers Dema -- http://dema.ruby.com.br - Rails from a .NET perspective
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 MessageLa...