search for: alias_method

Displaying 20 results from an estimated 114 matches for "alias_method".

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 ------------------ This is my helper: ------------------ module ApplicationHelper alias_method :rp, :number_to_currency_rp # Rp 1.907.000,00 instead of $1,90...
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) >> contents.symbolize_keys.each_value {|v| v.symbolize_keys } >> end >> end But after that last ''end'', irb explodes, saying: NameError: undefined method `l...
2006 Mar 12
1
a better way to alias methods
Hi is there a better way to accomplish this task? class PortfolioController < ProjectController layout ''portfolio'' def boing redirect_to :action=>:index end alias_method :new , :boing alias_method :destroy , :boing alias_method :edit , :boing alias_method :update , :boing end My portfolio controller implements view only control of the project controller therefore I want to prevent the user from poking around for sensitive methods inside the pro...
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? self.orig_recipe_type = guess_recipe_type self.recipe_type_is_guess = true else self.orig_recipe_type = t self.recipe_type_is_guess = false end end recipe_type is a...
2009 Sep 23
5
Overriding AR read/write_attribute - Overridden write_attribute Is Never Called
Could someone explain this? #config/initializers/ar_attributes.rb module ActiveRecord module AttributeMethods alias_method :ar_read_attribute, :read_attribute def read_attribute(attr_name) p "read_override" ar_read_attribute(attr_name) end alias_method :ar_write_attribute, :write_attribute def write_attribute(attr_name, value) raise ''You made it!'&...
2005 Nov 02
4
acts_as_metadata?
I''m running into the need (on at least one project now) to implement end-user-customizable "metadata" or properties on model objects. The standard example would be a Person class that had first_name, last_name, etc. but would need to be extended real-time (through the web admin interface) with properties such as phone_number : varchar (30). I''ve done some basic
2008 May 21
0
Problem with alias_method in a plugin
...l, so instance method also works. I''ve set breakpoints on both methods (meta_tag and foo) - calling model_instance.meta_tag doesn''t trigger debugger and model_instance.foo triggers debugger. So the redefined meta_tag method is not called at all. If I copy all this code (has_one, alias_method and redefine meta_tag) directly into the model it works fine. Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYP...
2008 Jan 28
4
Scheduling same worker/method at different times with different args
I need to run the same worker''s method twice per day with different arguments. Unfortunately, only the second entry in the schedule is firing. I created an experimental worker to verify this: Worker: class ExperimentWorker < BackgrounDRb::MetaWorker set_worker_name :experiment_worker def create(args = nil) # this method is called, when worker is loaded for the first time
2006 Jan 11
5
stack level too deep problem
...overload the link_to function, (to disable link_to if the user has no access right) this is my code, it work the first time I run the application, the second time I refresh the page I always get "stack level too deep error" module UsersHelper include ActionView::Helpers::UrlHelper alias_method :link_to_original, :link_to def permission? true end def link_to(name, options = {}, html_options = nil,*parameters_for_method_reference) if permission? link_to_original( name, options,html_options,*parameters_for_method_reference ) end end end the error message ho...
2006 Aug 16
3
AR: column methods?
...gt; false t.column "color", :string end If a dog''s tail indicates its own color, I want to use it. Otherwise, the tail''s color is the same as the dog''s color: class Dog < AR::Base has_one :tail end class Tail < AR::Base belongs_to :dog alias_method :tail_color, :color def color return tail_color if tail_color != nil return dog.tail_color end end The trouble is that the ''color'' method doesn''t exist yet: $ ./script/console Loading development environment. >> x = Tail.new NameError: undefined metho...
2006 Jun 01
3
more questions: human_name
One more question: Is there some way to set the human_name of a column? e.g.: human_name for column address1 shouldn''t be Address1 but "Address, line 1". If not, should I make a hash with my custom names? Best regards, -- ---------------------------------------------------------------------- Yannick Majoros http://www.inma.ucl.ac.be/~majoros Informaticien UCL/INMA-MEMA
2006 Feb 01
7
Explanation of "alias_method"
Hi! I''m trying to extend ActiveRecord''s find method (Rails 1.0, Ruby 1.8.2), but I recognize a strange behaviour of the "alias_method" call. I wrote a very simple script to explain my problem: ------------------------------------------------------ module ActiveRecordExtension def self.included(base) base.extend(ClassMethods) base.class_eval do class << self p "Alias...
2005 Sep 17
0
Reloading and redefining methods: infinite recursion
When I redefine a method like this class Klass alias_method :method_without_addition, :method def method_with_addition ... method_without_addition ... end alias_method :method, :method_with_addition end I get into trouble in the development environment. As these definitions are executed again for each request, the second time around met...
2006 Aug 14
0
ActionMailer in an infinite loop? Looks like framework bug.
...) end end The first line of this method is inherited_without_helper, but when I searched for this method I found that it was an alias for the same method. Here is where I found that problem: Line 15: helpers.rb: ActionMailer 1.2.5 --------------------------------------- class << self alias_method :inherited_without_helper, :inherited alias_method :inherited, :inherited_with_helper end Notice it''s defining inherited_without_helper to be inherited_with_helper so a call to inherited_without_helper is the same as calling inherited_with_helper! Hence the infinite loop. So I star...
2005 Aug 09
3
Adding created_by and updated_by trouble
Hi everyone. This is a real noob question that I''m hoping someone out there can help me with. I have followed the tutorial How to Ad created_by and updated_b<http://wiki.rubyonrails.com/rails/show/Howto%20Add%20created_by%20and%20updated_by>y and it works ok for retrieving the data. I''m using the Login_Generator. I cannot get it to work on create or update. I think
2006 Jul 27
9
Introspecting validates_presence_of
Hello people, I''d like to detect whether an attribute of a model has vaildates_presence_of applied to it so I can automatically apply a mandatory (*) to the field...it doesn''t look easy...any ideas? Cheers, -- Dan Webb http://www.danwebb.net
2007 Sep 05
6
Caveman Questions
Hello! I''m just a caveman with some caveman questions. I''ve been parsing Rspec for quite a while, and I''m writing my first series of specs. My initial impressions are "Verbose, but understandable. Helpful and intuitive, but so much to digest." I want to congratulate the folks who are dedicating a chunk of their lives to writing this, and ask 2 caveman
2005 Feb 08
2
test_process.rb => LoadError
Line 4 and following of test_process.rb reads: if defined?(RAILS_ROOT) # Temporary hack for getting functional tests in Rails running under 1.8.2 class Object #:nodoc: alias_method :require_without_load_path_reloading, :require def require(file_name) begin require_without_load_path_reloading(file_name) rescue Object => e ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } require_without_load_path_rel...
2007 Nov 17
7
Down with Lambda!!
Rspec is all about using natural language to define behavior. In this context, I feel that lambda is sorely out of place. I was chatting on #irc and a pal of mine (wycats) proposed an interesting alternative: alias_method :doing, :lambda so instead of something like lambda {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) we get doing {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) Now it reads like a sentence..much cleaner and less abstract to...
2006 May 18
2
attempt to override the ''tag'' method
...elpers::TagHelper to do some generalized error handling similar to the way scaffolding puts a red border around fields that fail validation. I''ve created a file lib/rails_patches/tag_helper.rb which contains the following. module ActionView module Helpers module TagHelper alias_method :orig_tag, :tag def tag(name, options = nil, open = false) breakpoint orig_tag(name, options, open) end end end end I then have a view with the following <h1>New post</h1> <%= start_form_tag :action => ''create'' %>...