search for: mixins

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

Did you mean: mixing
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 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) witho...
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
It seems to me that Validations are quite useful for many objects, even ones having nothing to do with ActiveRecord. Common examples are Contact Us forms, multi-step forms, web service paramater validations, etc. I took a look at the source for Validations, and it seems that it is very independent from ActiveRecord. I caught only three depenedencies: 1. validates_numericy --> depends on
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(include...
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...
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?
...sers 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 little code snippets/mini-libraries for Camping? Is the wiki the best place? I think a lot of camping code could be re-used via mixins and it would be nice to have a Camping-forge type place to go find existing work. Cheers, -Mark
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 compa...
2008 Dec 09
7
subclassing vs mixins, which one should be used?
...ds 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 ahead of time --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To pos...
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 Nov 14
3
[UHH] any blogs sprung from camping?
Hello, I just joined the camping list. I was trolling the archives when I saw this: -- The biggest problem in Camping is authentication. This is a problem I propose to solve by providing an extension. That little bit of code uses the path to allow/disallow urls. That way it is unobstrusive. In the future I would also like to make an OpenID client and server for Camping. -- I was wondering if
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
I''ve been working on a plugin called Http Test where I add HTML validation and link checking to controller and integration tests through an after filter in ApplicationController. I used to mix in a bunch of methods that I needed into the ApplicationController class, but to me this had a bad smell, so I broke much of the code out into separate classes that I delegate to.
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 brings...
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 MessageLabs.