Displaying 20 results from an estimated 400 matches similar to: "mixins not reloaded as expected?!"
2007 Feb 08
0
derive.js - Ruby-esque derivation/mixins for Prototype
All,
I whipped up a small extension for Prototype to solve 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
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.
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.
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
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 Mar 05
8
Model Inheritance, Mixins and Database design
I''m trying to understand how best to use inheritance and wonder if
Rail''s Single Table Inheritance model too restricting.
I have a model Companies who provide 1+ Services (HABTM relationship).
I assume the best way to represent this is with a series of child models
representing each type of service : ServiceType < Company.
I want to return lists of companys for each
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
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
--
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
2011 Dec 05
1
How to extend common helper methods to view specs?
Hi, there,
I have some methods which I have written as helpers.
They are in spec/support/controller_macros.rb (yes, I will change the
name soon).
The 2 methods, login_user and login_admin_user works in the
controller specs BUT fail to work in the view specs when I call them
in the view specs.
---------- spec/spec_helper.rb start --------------------------
# This file is copied to spec/
2005 Dec 15
5
Rails vs. J2EE: Sharing state in memory?
Hi,
I am from a Java background and pretty new to Ruby and Rails.
What I am wondering is how I would shared state accross requests and users
without involving IO, i.e. use memory.
My current understanding is that for each request a new process ist spawn
and therefore it gets its own memory. So no sharing can take place between
requests?
Do I understand this right? For those who know
2006 Mar 21
4
Determining Browser?
Is there a way I can read the user agent or something similar to
determine whether the person is using IE, Mozilla/Netscape, Opera,
Safari, etc? I want to dynamically output the CSS to the browser, but
I''d like to change certain things (in this case the widths of some
divs since IE adds borders and padding size to the total size of a div
unlike firefox).
Thanks,
- Brent
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]
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 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
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 31
1
SVN revision 218: errors and failures under win32.
Zed:
1) Error:
test_more_web_server(HandlersTest):
EOFError: end of file reached
I solved this changing the following lines in test_handlers.rb:75-76
res = hit([ "http://127.0.0.1:9998/",
"http://127.0.0.1:9998/test",
I cannot solve the other failures:
1) Failure:
test_header_is_too_long(WebServerTest)
[./test/test_ws.rb:93:in
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)