Displaying 20 results from an estimated 600 matches similar to: "Explanation of "alias_method""
2005 Dec 17
2
Storing an object in the db
I''ve asked this before, but never got a working response. I''d like to
store an object inside a binary field in my db. So I''d have a class
like this
class MyAwesomeClass
def do_something_awesome
...
end
end
then
class MyRecord < ActiveRecord::Base
end
the table my_record would have a binary field, my_object, that would
store an object of
2008 Jul 28
1
callback executed like after_save but after transaction
I''m trying to add some code for my ActiveRecord class so that it is
executed whenever an object is updated, this code is a seperate
process that reads from the same table represented by my model class
so when it runs it needs the database to be up to date.
In the following situation this is fine:
# MyModel
def after_save
`/usr/local/bin/update_models -i #{self.id}`
end
# controller
2011 Apr 07
1
Adding text to page margin with lattice graphics
R: 2.12.1
OS X
Colleagues
I am working with lattice graphics for the first time and I am confused by some aspects of controlling these graphics. The most pressing issue is the following:
I can print the graphics without problems with the command:
print(MYFUNCTION(SOMEOBJECT)
However, I would like to add margin text (this terminology might not apply in this setting). I am able to do so with
2006 Feb 07
4
Ruby, Rails & Inheritance
Hi!
I am looking for a solution for the following problem:
Some of my models share some attributes and also was in need for some
extra features, so I created a class "RecordWithFeatures":
-----------------------------------------------------------------
class RecordWithFeatures < ActiveRecord::Base
# @Override
def self.descends_from_active_record?
superclass ==
2006 Mar 12
1
alias_method interferes ApplicationHelper
Hello,
I''m using Ruby 1.8.4 (darwinport), rails-1.0.0 (gem) , Powerbook / Mac
OS X 10.4.5 , Webrick.
How come Rails always raises NoMethodError for my helper (must_fill and
rp or number_to_currency_rp) in application_helper.rb ?
I doubt that alias_method is the culprit, but if i give #
comment then there will be no errors at all ... :/
what am i doing wrong? is it a bug or stupid me? Thx
2008 Jan 18
2
NameError when using alias_method -- but method exists?
Hello Rubyists,
I am a bit stumped here. I want to extend the ''load_file'' method in the
YAML module. Following along with the PickAxe example of making old
methods do new things, I try this in irb:
>> module YAML
>> alias_method :orig_load_f, :load_file
>> def load_file(*args)
>> contents = orig_load_f(*args)
>>
2007 Feb 26
2
undefined method ... from `alias_method'
0 wicked var/www % ./script/console
Loading development environment.
>> r = Recipe.find :first
NameError: undefined method `recipe_type='' for class `Recipe''
from ./script/../config/../config/../app/models/recipe.rb:
101:in `alias_method''
In recipes_controller:
alias_method :orig_recipe_type=, :recipe_type=
def recipe_type=(t)
if t.nil?
2006 Jan 31
11
ez_where plugin updated features.
Friends-
I wanted to let people know that there is a new experimental release
of this plugin. I would love feedback on syntax and features. There
is now a full test suite with fixtures that covers all the available
syntax. Look at the test suite for more syntax possibilities. There
have been many additions since my last release. Fabien Atelier has
been working on this with me and has
2008 May 21
0
Problem with alias_method in a plugin
Hi,
I''m doing my first plugin, based on attachment_fu structure. Here''s
the code: http://pastie.caboo.se/200797.
The problem is that the meta_tag method doesn''t seem to be
overwritten.
I can call model_instance.original_meta_tag and it return same thing
as model_instance.meta_tag, so the aliasing works.
I can call model_instance.foo and it correctly returns class of
2006 Aug 17
6
Creating Custom Events using prototype
Hi guys!
i know prototype can create custom events and can subscribe to it, but is
there already a library for this?
thanks!
--
<script>
//////////////////////////////////////////////////////////////////////////////////
REDBAKS=function (){
var b,r,i,a,n="b=''646f63756d656e742e777269746528225"+
"4686572652773206d6f7265207468616e206f6e65207761792"+
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/.
2006 Feb 01
2
IE memory fix leak.
By default the prototype.js gives us the function
/* prevent memory leaks in IE */
Event.observe(window, ''unload'', Event.unloadCache, false);
But there is no unload event in out application as the content of the div
keeps changing using the Ajax.Updater function. To handle such a scenario,
we''ve added the following lines of code to prototype.js
/* prevent
2009 Jan 20
2
problem with writing data to *.xls file
Hi all,
I read data from *.xls file and i did some caliculations on that data and
now i have to create a column in the same .xls file
and i have to insert the data in to the consicutive rows related to the
previous data
i tried it with *write.xls() *but the thing is it deleted all the columns
previously presented in that file and it created a column and inserted data
can any one suggest what to do
2011 Mar 22
25
RFC: Splitting up the file{} type functionality.
The file{} type can do all of the following:
* manage single files
* manage directories
* manage symlinks
* manage recursive file copies
The intersection of all these bits of functionality makes it difficult
to understand exactly what is going on when you''re new to Puppet, and
even experienced users often don''t know how combining symlinks/content
management is going to work.
2009 Apr 19
19
Controller spec: testing that scope is set
In a Rails controller I set the scope on a model class in an around
filter. I have defined expectations on the model classes, and ideally, I
would add a further expectation for the scope. Is this already possible
in some way? How would I go about adding support a scope expectation?
Michael
--
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/
2006 Apr 20
11
dynamic mock object anyone?
Hi guys, got this problem with creating such a thing... hope anyone
could help..
the problem:
ok, now i have this mock object that would simulate a external rpc call.
eg
require ''models/xmlrpc_agent''
class XmlrpcAgent
def create(params)
200
end
end
but the value of the value returned is fixed. which is quite hard for me
to test the controller when different
2006 Feb 22
8
filtering "tags" via checkboxes - HABTM
First post/newbie post... bear with me.
What I''m trying to achive (music site):
A system containing tracks and moods with a HABTM relationship. I''ve
got all that set up and functioning in the admin environment - i.e.
admins can apply a variety of moods to a particular track via a
series of checkboxes. Join table works just fine.
I''m currently stuck on allowing
2006 Nov 01
17
So how can I rewrite my app without using with_scope?
So, I hear that with_scope is going to be deprecated.
Which is a bit of a shame, given the stuff I''ve been writing recently.
I have a CMS with multiple clients. A ''client'' is essentially a
company, with multiple users. Content on the site belongs to a client
- content could be messages, images, schedules, etc etc. People
belonging to one client should not be able
2006 Jul 14
5
Acts_As_Taggable Plugin multiple controllers.
I have Acts_As_Taggable Plugin working. I have a HR controller and a
sales controller.
I have a document in hr tagged whitepaper and a differnent document in
sales tagged whitepaper
when I am in hr I see the hr document tagged with whitepaper and not
the sale document (what I want). but if I click on the tag whitepaper
I return two documents, hr and sales. I just want to return the hr
document
2007 Oct 18
9
with_scope issue
I have the following code:
class User < ActiveRecord::Base
has_many :requests do
def find_active(options = {})
with_scope :find => { :conditions => ["requests.active = ?",
true] } do
find(:all, options)
end
end
end
end
Executing user.requests.find_active results in the following SQL:
SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND
(