similar to: What's the difference between mattr_accessor and cattr_accessor in ActiveSupport?

Displaying 20 results from an estimated 1000 matches similar to: "What's the difference between mattr_accessor and cattr_accessor in ActiveSupport?"

2006 Jan 05
0
cattr_accessor
Is this specific to rails? What''s it used for and when is it approriate to us it? Is there also a mattr_accessor? -- Posted via http://www.ruby-forum.com/.
2012 Sep 09
2
mattr_accessor inside a class
Rails extends Ruby with mattr_accessor (Module accessor). As Ruby''s attr_accessor generates getter/setter methods for instances, mattr_accessor provide getter/setter methods at the module level. In below example, you see that mattr_accessor declared in the class context of LookupContext. It''s declared in class, not module. However, modules are defined in LookupContext, for
2006 Sep 05
5
cattr_accessor
Hi, i''ve been playing with ror for a little over two months now, and was wondering wether someone could explain to me what was cattr_accessor and if it is still in use. . . i looked up in api.rubyonrails.com and coulnd''t find any documentation... is it a useful/worth learning method? what do u use it for? -- Posted via http://www.ruby-forum.com/.
2013 Apr 08
1
cattr_accessor and Thread.current prblems
Hello, I am trying to convert three applications to multitenant, all of them have same structure difference is only in little functions and template designs. All of them using cattr_accessor for setting currencies and other data, and it works perfectly Now i added app_id as cattr_accessor to App model to use it in default_scope to implement multi-tenancy class App < ActiveRecord::Base
2006 Sep 04
2
"include" versus "extend" - what's the difference
Hi, Just wondering when one would use "include" over "extend"? Both seem to bring in methods to the class no? The context is I''m just trying to understand why both are used with the acts_as_audited plugin: Full extract from plugin (used within here): ================================================== # Copyright (c) 2006 Brandon Keepers # # Permission is hereby
2006 Mar 29
0
cattr_accessor missing for test of AR
Hello. I''m trying to test an active record adapter. When launching : ruby -I "connections\native_adaptername" anytest_test.rb I have an method missing error, complaining about cattr_accessor (missing from AR:Base). Any advice ? Tony PS : ruby 1.9, rails 1.10 install via gems -- Posted via http://www.ruby-forum.com/.
2008 Feb 27
0
Activesupport error on start - extract_options
I''m trying to get Rails up and running on a new port of Ruby to Arm/WinCE devices that I''ve been working on, built using CEGCC tools for ''mostly'' Posix compatability, rather than using the existing Ruby WinCE binaries. Ruby runs and is installed under \ruby in root of the device itself. I''ve edited the following files of a default Rails 2.0.2 *zip*
2012 Sep 22
4
Class, Module, Object
>> reload! Reloading... => true >> puts Class < Module true => nil >> puts Module < Class false => nil >> puts Module < Object true => nil >> puts Object < Module false => nil >> Object.parent => Object The above indicates that the Class object instance inherits from the Module object instance and the Module object instance
2006 May 05
1
class_eval in ROR''s attribure_accessor.rb
hi, here is a snippet code in ROR''s attribure_accessor.rb. the usage of class_eval is different with "class_eval(string, <, file, <line>>)" somewhat, i don''t understand this usage, who can explain it more detail to me? def cattr_writer(*syms) syms.flatten.each do |sym| class_eval(<<-EOS, __FILE__, __LINE__) unless defined?
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
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2011 Feb 11
0
rails 3 initialize module, running cucumber
I have this in my environment file, I get "The error occurred while evaluating nil.[] (NoMethodError)" on the S3Config.key= line when running cucumber. Why is it not loading up the module when running cucumber? module S3Config mattr_accessor :key mattr_accessor :sec end class ActiveRecord::Base include S3Config extend DynamicMethods end S3Config.key =
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
2006 Feb 02
4
rails-1.0.0 gem rdoc problem
Just got a brand new install of ruby-1.8.4 and new gems downloaded, specifically rails-1.0.0. Seems rails does not generated rdoc for gem_server. Looking into the problem, it seems that there is an error when doing ''rake rdoc'' for rails-1.0.0. % rake rdoc (in /opt/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/rails-1.0.0) rm -r doc unrecognized option `--line-numbers --inline-source
2008 Dec 31
1
when to set a class attribute variable during boot
I have an ActiveRecord model with a cattr_accessor. The class attribute is set up like this: class MyModel < ActiveRecord::Base cattr_accessor :my_attribute end Because I need to give #my_attribute environment-specific values, I try to set this attribute in environments/development.rb like so: MyModel.my_attribute = 3 But this leads to odd and erratic behavior when #my_attribute is called
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 method_without_addition is actually the
2006 Aug 14
0
ActionMailer in an infinite loop? Looks like framework bug.
I would rather post this on the dev list since it looks like only the developers can explain why this is failing. However, I can''t find where you subscribe to it! Any ideas? Here is my problem. Whenever I try to send an email I get a SystemStackError saying stack level too deep. Here is the exception trace:
2011 Jul 11
2
Can't get this Rspec test to pass
Hello, I''m completely new to Rspec testing and I''m finding it very difficult to mock specific objects. In this test, I have a before block setup as such: [code] before do setup_controller_for_warden controller.session[:operation_id] = 1 @operator = Factory :operator sign_in :operator, @operator @persist_herd = Herd.new
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?