search for: alias_method_chain

Displaying 20 results from an estimated 63 matches for "alias_method_chain".

2009 Oct 21
3
alias_method_chain and ActiveSupport::TestCase
I''m trying to add some functionality to the setup method of all my tests. I added a method called setup_with_ts in the test_helper and chained it using alias_method_chain :setup, :ts and that works great for every test that does not define setup in the test. So for my unit tests i tried also defining the same method setup_with_ts in a class ActiveSupport::TestCase def setup_with_ts puts "setup with ts" setup_without_ts end alias_method_chain...
2009 Jan 20
0
alias_method_chain in Facebooker Causing Stack Level Too Deep
I installed the Facebooker plugin and upon placing it on a staging server, I keep running into stack level too deep errors. It seems to stem from Facebooker using alias_method_chain to override some of the ActionController methods. I believe it''s getting loaded twice causing confusion. I''ve tried various methods include wrapping a unless respond_to?(:method) around the alias_method_chain call to keep it from being called twice. However, none of this has wo...
2006 Dec 26
0
alias_method_chain vs. redefined method with super
I''m trying to fully understand the subtleties of using alias_method_chain to refine method behavior versus redefining a method and calling super. I have a simple data model (a music collection) that I often use to evaluate web frameworks, and I''m trying to get it working on Rails 1.2.0RC1. Specifically, I have three classes which subclass a common Artist class...
2006 Aug 16
0
acts_as_paranoid and alias_method_chain
when i require acts_as_paranoid I''m getting: undefined method `alias_method_chain'' for #<Class:ActiveRecord::Base> (NoMethodError) It happens in acts_as_paranoid''s init.rb. here''s the whole file. the alias_method_chain is near the bottom. please advise. class << ActiveRecord::Base def belongs_to_with_deleted(association_id, options...
2007 Apr 12
0
Does Ferret have problems with #alias_method_chain ?
...:fields => (self.content_columns.map(&:name) rescue []) + %w(main_identifier) class << self # #count is also defined, omitted for clarity def find_with_destroyed_scope(*args) with_destroyed_scope do find_without_destroyed_scope(*args) end end alias_method_chain :find, :destroyed_scope def with_destroyed_scope(&block) raise "Called without a block" unless block_given? with_scope(:find => {:conditions => "destroyed_at IS NULL"}) do yield end end end end When I start the Ferret server and su...
2007 Mar 22
0
`alias_method_chain': undefined method `find' for class `ActiveRecord::Base' (NameError)
I can''t seem to be able to override the :find method in the model base class, for example, in /lib/usermonitor.rb: module ActiveRecord module UserMonitor def self.included(base) base.class_eval do alias_method_chain :find, :user def current_site Thread.current[:user] end end end def find_with_user(*args) ... end end end I got this error: `alias_method_chain'': undefined method `find'' for class `ActiveRecord::Base'' (NameError) How...
2007 Jun 12
1
alias_method_chain and Class methods (a Ruby question)
Hello list, I am trying to override the post_form method of Net::HTTP so that it does something before actually doing the post. I tried the following in environments/development.rb module Net class HTTP alias_method_chain :post_form, :intercept def post_form_with_intercept(url, params) # Do something before post logger.info(''About to post at #{url}'') post_form_without_intercept(url, params) end end Unfortunately this complains that there in no method called post_...
2008 Mar 28
1
undefined method ''alias_method_chain''
Running Rails 2.0.2, I get this error: ./script/../config/../vendor/plugins/facebooker/lib/facebooker/rails/facebook_url_rewriting.rb:29: undefined method `alias_method_chain'' for ActionController::UrlRewriter:Class (NoMethodError) from /usr/local/rubygems/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' from /usr/local/rubygems/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' from ./script/../...
2009 Dec 29
1
undefined method `alias_method_chain' for I18n::Backend::Simple:Class
Hi, We are running RE: ruby 1.8.7 (2009-06-12 patchlevel 174) [sparc-solaris2.10], MBARI 0x8770, Ruby Enterprise Edition 2009.10 I tried a simple web app with a controller rendering a text and is working in my PC but on the server I get: Error message: undefined method `alias_method_chain'' for I18n::Backend::Simple:Class Exception class: NoMethodError Application root: /sites/rails-data/apps Backtrace: # File Line Location 0 /usr/ruby-enterprise/lib/ruby/gems/1.8/gems/activerecord-2.3.4/ lib/active_record/i18n_interpolation_deprecation.rb 23 1 /usr...
2010 Jul 23
0
alias_method_chain with i18n
...######### include WillPaginate::ViewHelpers def will_paginate_with_i18n(collection, options = {}) will_paginate_without_i18n(collection, options.merge(:previous_label => I18n.t(''will_paginate.previous''), :next_label => I18n.t(''will_paginate.next''))) end alias_method_chain :will_paginate, :i18n ############################################# What I would like to understand is how this code is working, the "magic" behind it. I''m also having a problem with this code with passenger. The code works fine with webrick but with passenger the program break...
2008 Nov 23
4
Strange behavior of alias_method_chains
Greetings. I''ve got very strange behavior of alias_method_chains, and I hope someone will advise me. I have a rails 2.2.2 app created with #rails aliasApp , a class XYZ residing in app/helpers/xyz.rb: <code> class XYZ attr_accessor :name attr_accessor :value def initialize (a, b) puts "in XYZ constructor" self.name = a se...
2007 Aug 30
1
alias_method_chain stack level too deep in Rake test only
...g module: module ActionController module SslSupport def self.included(base) raise "#{base} does not define url_for" unless base.method_defined?(:url_for) unless base.respond_to?(:url_for_without_ssl_supprt) base.send :include, InstanceMethods base.send :alias_method_chain, :url_for, :ssl_support end end module InstanceMethods def url_for_with_ssl_support(options) new_options = options.dup if options.kind_of?(Hash) new_options.merge!({ :only_path => false }) if request.ssl? ^ url_ssl?(new_options) if url_s...
2007 Oct 04
3
Is stubbing a call to super possible?
Hi Is stubbing a call to super possible? I am testing a protected method called authorized in a Rails controller ... part of the logic flow calls super which calls the method authorized in the application controller. As I am focused on the logic of the method in the controller I am testing I just wish to stub the value returned in the super. Is this at all possible? Cheers Shane
2011 Apr 08
5
How to extend a helper using plugin?
Hello, I''m facing this problem while trying to extend the parse_redmine_links helper method in Redmine-1.1.0 (Rails-2.3.5) from my plugin. My idea is to use alias_method_chain so the extended version could call the original version and adjust the result to it''s liking. Anything I''ve tried so far exposes this behavior: the first render of a page uses the extended version, while every later renders use the original unmodified helper. I''ve tried...
2009 Nov 10
10
Un-recognised routes that do exist, using namespaces & subdomain checking
...ybe RSpec is doing something different with the request, as if I monkey patch the routing with the following I never get the dumps when using RSpec even though both these are called pretty early on in route recognition. module Foo module RouteSetExtensions def self.included(base) base.alias_method_chain :extract_request_environment, :debug base.alias_method_chain :recognize_path, :debug end def recognize_path_with_debug(path, environment={}) puts path puts environment.to_yaml recognize_path_without_debug(path, environment) end def extract_request_environme...
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
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)
2009 Aug 17
1
Problem with setter override on ActiveRecord
...rowse%5Fthread/thread/4fe057494c6e23e8, so finally I could had some working code: class Book < ActiveRecord::Base belongs_to :author def author_with_lookup=(author) author = Author.find_or_initialize_by_name(author) if author.is_a? String self.author_without_lookup = author end alias_method_chain :author=, :lookup end This time, the console was nice to me: >> book = Book.new(:name => "Alice''s Adventures in Wonderland", :pub_year => 1865) => #<Book id: nil, name: "Alice''s Adventures in Wonderland", pub_year: 1865, author_id: nil, crea...
2007 Aug 21
3
Eager Loading
is there a way to always eagerly load an associated object so that you don''t have to put :include into every finder? class Product <ActiveRecord::Base belongs_to :user #always load user when product is loaded end Product.find(1).user.login #1 query since user was loaded with the product, same as if i used :include but I don''t want to have to specify it everywhere.
2006 Jun 15
1
Unicode hacks - problem
...\workspace\auth_template>mongrel_rails start ** Starting Mongrel in development mode at 0.0.0.0:3000 ** Starting Rails in environment development ... C:/ruby_projects/radrails/workspace/auth_template/config/../vendor/plugins/scoped_access/init.rb:17:in `load_plugin'': un defined method `alias_method_chain'' for #<Class:Dispatcher> (NoMethodError) from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/initializer.rb:348:in `load_plugin'' from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/kernel/reporting.rb:11:in `s ilence_warni...