search for: append_featur

Displaying 20 results from an estimated 25 matches for "append_featur".

Did you mean: append_features
2012 Sep 20
2
append_features(mod)
append_features(mod) The documentation says: When this module is included in another, Ruby calls append_features in this module, passing it the receiving module in mod. Ruby’s default implementation is to add the constants, methods, and module variables of this module to mod if this module has not already been...
2011 Feb 09
0
Weird error after upgrading to rails 3.0.4
...ethods /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.4/lib/active_model/ validations.rb:50 /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/ active_support/concern.rb:52:in `class_eval'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/ active_support/concern.rb:52:in `append_features'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/ active_support/concern.rb:48:in `include'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/ active_support/concern.rb:48:in `send'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/ active_supp...
2006 Jun 21
1
Plugin Panic! - no accessing a model''s class methods?
...nce none create new instances of their calling model class). full plugin contents follow. *whimper* help? -- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com # ActsAsCopyable module FakeActiveRecord module Acts #:nodoc: module Copyable #:nodoc: def self.append_features(base) super base.extend(MacroMethods) end # declare the class level helper methods which # will load the relevant instance methods # defined below when invoked module MacroMethods def acts_as_copyable include FakeActiveRecord::Acts:...
2006 Feb 28
1
Cache Magic field for totaling
Hello, Rails provide counter cache field for associations, I want a similar cache for totaling up values (say account_balance = sum_of_deposits - sum_of_withdrawals). I was wondering if rails, already has another surprise in store for me, or is there any plug-in or how-to for doing these kind of things. Thanks. -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com Read the
2007 Feb 02
0
Problem with ActiveForm
...NameError: undefined method `save'' for class `Object'' from /usr//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/validations.rb:216:in `alias_method'' from /usr//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/validations.rb:216:in `append_features'' from /usr//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/validations.rb:215:in `class_eval'' from /usr//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/validations.rb:215:in `append_features'' from (irb):4:in `include...
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/.
2013 Jun 08
1
ActiveSupport::Concern support Module#prepend?
...er/lib/easy_auth/active_support/concern.rb My monkey patch work for what I''m trying to do but I suspect a better implementation would actually have @_dependencies be an array of arrays with each set being the module in the first element then :include or :prepend in the send. Then when `append_features` or `prepend_features` iterates over @_dependencies the send element will be used to call the proper inclusion method. The only wild card is how ClassMethods will get extended. My understanding is that extend will append class methods to the base class. I cannot seem to find a prepend versio...
2006 Mar 23
1
Need installation Help
...1.0.0/bin/../lib/rails_generator/lookup.rb:33:in `user_home'' from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/bin/../lib/rails_generator/lookup.rb:106:in `user_component_sources!'' from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/bin/../lib/rails_generator/lookup.rb:54:in `append_features'' from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/bin/../lib/rails_generator/lookup.rb:38:in `include'' from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/bin/../lib/rails_generator/lookup.rb:38:in `send'' and a stream of others. I am at a loss. Can anyone advi...
2008 Jun 24
2
wrong number of arguments (1 for 0) when using respond_to?
Trying to get an otherwise working app (in Rails 2.0.2) up to speed with Rails 2.1.0 and Ruby 1.8.7, I have some broken code I can''t seem to fix: module Pathmaker def self.append_features( base ) base.before_save do |model| model.path = model.name.downcase. gsub( /\ and\ /, ''-'' ). gsub( /\ on\ /, ''-'' ). gsub( /[^a-zA-Z0-9\-]/, ''-'' ). gsub( /[\-]+/, ''-...
2006 Jun 01
5
History plugin
Hello, I felt annoyed enough when having to redirect user back to their previous location in a hackish way that I wrote this plugin. It avoids storing POST and Ajax request. It also has a facility to specify actions not to store in the history. If you are interested, it''s there: http://blog.cosinux.org/pages/rails-history See you all, Damien -- Damien MERENNE
2006 Mar 13
1
adding custom cache field
...'. And while declaring the models just add the line, belongs_to_extra :accounts, :total_cache => :amount This code below is tested with edge rail, and will work for polymorphic associations also. Any comments are welcome. module ActiveRecord module Associations # :nodoc: def self.append_features(base) super base.extend(ClassMethods) end module ClassMethods def belongs_to_extra(association_id, options = { }) association_type = association_id.to_s + "_type" if association_id association_primary_key = association_id.to_s + "_id&quot...
2006 May 17
3
Help mixin in class methods
Starting to feel more confident and code is DRYing up nicely, but I''ve hit a brick wall here and hoping someone can help me. I''ve got a module, TrustRanking, which extends a number of model''s instance methods, and I want to extend their class methods too, but I can seem to work out how to do it. Simply including the module from the class works a treat for the
2006 Jul 04
1
How to override ActiveRecord#base#destroy
...Rails to work with that table quit good. Except for the destroy() action. From the resulting trace I can see that the old version of destroy() is called from transaction.rb. I think this lines might be the reason that I''m unable to override detroy(): from transaction.rb def self.append_features(base) super base.extend(ClassMethods) base.class_eval do alias_method :destroy_without_transactions, :destroy alias_method :destroy, :destroy_with_transactions ... Any ideas, hints, etc.? best regards, Torsten
2006 Jan 02
0
Extending a model in a component...
...end User.send(:include, MyUser::Acts::Chicken) This just mixes in the new method. But if I add a ''has_many'', I get an error. I''ve tried using the way to extend ActiveRecord (like in a plugin), but that''s not working either. module MyUser def self.append_features(base) super base.extend(ClassMethods) end module ClassMethods def my_new_method end end end User.send(:include, MyUser) I''m not understanding the basics of extending a class, not just mixing things in. Any pointers on this?...
2006 Jan 06
0
bug rails activerecord association join
...f using class_name method but it gives the parent class''s name in STI (I dont know if its the desired behaviour or is it also a bug) Is there a better way of doing this? I wanna submit a patch but couldnt be sure if I did it correct. module ActiveRecord module Associations def self.append_features(base) super base.extend(ClassMethods) end module ClassMethods private def association_join(reflection) case reflection.macro when :has_and_belongs_to_many " LEFT OUTER JOIN #{reflection.options[:join_table]} ON " +...
2012 Sep 28
0
Overriding class_attribute writers and order of super/extend C.M./included block eval in ActiveSupport::Concern
...d it is a little confusing when the order of things is typically to put included at the top even though it isn''t evaluated before ClassMethods is extended, etc. I''m not sure if it would help, but would be nice if the order of the following that happen in Concern''s def append_features(base) method were different and maybe then I could just override things in the ClassMethods module for class methods and the main block of the module for instance methods: super base.extend const_get("ClassMethods") if const_defined?("ClassMethods")...
2007 Sep 18
2
Making attachment_fu polymorphic
...e. This software comes with no warranty, ## expressed or implied. ############################################################################################# @@attachment_config = [] @@validates_as_attachment = nil # adds methods to the class that is mixing the module in def self.append_features(someClass) @@klass = someClass def someClass.has_polymorphic_attachment(config) @@attachment_config = config end def someClass.validates_as_polymorphic_attachment @@validates_as_attachment = true end super end # may only work for macs. If this is g...
2007 Nov 29
27
Strip & Sanitize BEFORE saving data
So I''ve googled my brains out, and I see a lot of talk about TextHelper for views, but next to no discussion about cleaning text _before_ it is saved. I figured this had to be asked 4 zillion times, but I''m not finding anything concrete/obvious. Using h is fine as a safety catch, but that alone is not acceptable to me as the means of diffusing the impact of HTML or JS
2006 Feb 01
4
exclude a column in save!
Hi all, I have a column that peeks its value from a sequence (postgres) some times. Other times, I set it to a certain value. This column has a default value of "nextval(''the_sequence'')"... When I want that this column peeks the value from the sequence, I do this: obj = Mymodel.new obj.some_column1 = blah obj.some_column2 = blah obj.some_column3 = blah obj.save! but
2005 Dec 02
43
ANN: acts_as_ferret
...or init.rb require ''acts_as_ferret'' # END init.rb # CODE for acts_as_ferret.rb require ''active_record'' require ''ferret'' module FerretMixin #(was: Foo) module Acts #:nodoc: module ARFerret #:nodoc: def self.append_features(base) super base.extend(MacroMethods) end # declare the class level helper methods # which will load the relevant instance methods defined below when invoked module MacroMethods def acts_as_ferret extend...