search for: class_ev

Displaying 20 results from an estimated 158 matches for "class_ev".

Did you mean: class_dev
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 defi...
2005 Dec 29
3
Why do plugins use class_eval?
I''m writing my own plugin and all the plugins I''ve seen use class_eval in the method that is called in the including module. For example: http://wiki.rubyonrails.com/rails/pages/HowToWriteAnActsAsFoxPlugin module Foo module Acts #:nodoc: module Fox #:nodoc: def self.included(base) base.extend(ClassMethods) end # declare th...
2008 Nov 19
3
Mock today
...s no argument, I want to have Date.today be a specific date for the purpose of testing. In other words, I want to do something like this: mock_today(Date.new(2008, 2, 1)) do ... test code... end My implementation for mock_today is: def mock_today(date) $_mock_test_date = date Date.class_eval do class <<self alias original_today today end def self.today $_mock_test_date end end yield Date.class_eval do class <<self alias today original_today end end end So my questions are: 1) Is it a good...
2008 Aug 23
0
Why ActionController::Base.class_eval for includes?
Just out of curiosity, why does action_controller.rb include classes with class_eval instead of directly? I.e., why ActionController::Base.class_eval do include ActionController::Flash include ActionController::Filters ... end instead of just class ActionController::Base include ActionController::Flash include ActionController::Filters ... end -- Posted via http:...
2011 Jul 06
5
Monkey patching a gem (rails_admin, with Rails 3)
Hi. I''m trying to monkey patch the rails_admin gem. First, I tried to add a file in config/initializers containing: RailsAdmin::MainController.class_eval do def get_sort_hash CODE HERE... end end It was only loaded once, and then the method from the gem was always executed instead of mine. I also tried to add the code in lib/ with the correct line in config/application.rb to load all files in lib/. But in this case it does not work at all. E...
2005 Sep 11
3
Extending ActiveRecord::Base
Hey everyone, I''m interested in extending ActiveRecord::Base. I have a special "easier" find function that I want to include in all classes. How can I include this in all classes? Can I just create a model object that does something like this: class ExtendedAR < ActiveRecord::Base def self.special_find ... end end and then all my other classes
2007 Sep 10
2
Removing an AR class definition, for testing plugins
I''m writing an acts_as_* plugin and am trying to BDD it. Ideally my specs would look like: describe ActsAsCloneable, " basic cloning" do load_example_classes School.class_eval do acts_as_cloneable end before(:each) do @old_school = School.create! :name => "Baylake Pines", :city => "Virginia Beach", :guid => "abc123" @clone = @old_school.build_clone end it "should preserve the attributes" do @clo...
2009 Apr 08
4
Having trouble extending a class from a Rails plugin
I have class in a plugin that I want to crack open and add some functionality to for a particular application. So, I created a file by the same name as the class in my app/models folder and added some methods to the class, but, I can''t seem to get Rails (2.2.2) to pick-up the extended definition. I did find while trying to debug the problem that if I paste the extended definition into,
2006 Sep 04
2
"include" versus "extend" - what's the difference
...# # == Database Schema # def acts_as_audited(options = {}) # don''t allow multiple calls return if self.included_modules.include?(CollectiveIdea::Acts::Audited::InstanceMethods) include CollectiveIdea::Acts::Audited::InstanceMethods class_eval do extend CollectiveIdea::Acts::Audited::SingletonMethods cattr_accessor :non_audited_columns, :audited_user_class_name, :audited_user_method self.non_audited_columns = [self.primary_key, inheritance_column, ''lock_version'', ''created_at...
2005 Dec 14
1
just installed rails on ubuntu, error creating rails dir -->unexpected token: ''#<RubyToken::TkLPAREN:
...5/lib/active_support/dependencies.rb:200:in `const_missing'': uninitialized constant Soap (NameError) from /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service.rb:57 from /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service.rb:55:in `class_eval'' from /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service.rb:55:in `class_eval'' from /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service.rb:55 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `...
2013 Aug 21
3
syntax error, unexpected tRPAREN raised in server log
In my server log, I am seeing this error message that is raised in activesupport. 2013-08-12T23:06:08.932580+00:00 app[web.2]: SyntaxError (/app/vendor/bundle/jruby/1.9/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:374: syntax error, unexpected tRPAREN 2013-08-12T23:06:08.932580+00:00 app[web.2]: 2013-08-12T23:06:08.932580+00:00 app[web.2]: def () value = nil
2006 Jul 24
1
Injecting actions into controllers
...should inject an action into the controller. Please note, not just an instance method, but also an _action_, one of those that are listable by running ControllerClassName.action_methods. I wrote the following code: def render_field_search(name, object, controller, options = {}) controller.class.class_eval do define_method("#{name}_flt") { raise ''Here iam!'' } end # this should define the new method as an action too controller.class.action_methods << "#{name}_flt" [..] end It works if I try to call the method from inside render_fiel...
2006 Sep 20
0
boy, that mongrel_upload_progress handler sucks!
...g a request_abort callback to handlers, but I found a simple way to monkey patch that in: # config/mongrel_upload_progress.conf # yes, this file is being used with -S meaning it''s an actual ruby file. # So, why don''t I use the rb extension? Hell if I know :) Mongrel::HttpHandler.class_eval do # add the default stub method def request_aborted(params) end end # patch the monkey Mongrel::HttpRequest.class_eval do def initialize_with_abort(params, socket, dispatcher) initialize_without_abort(params, socket, dispatcher) dispatcher.request_aborted(params) if @body.nil? &...
2010 Aug 10
2
undefined method `has_many' for Object:Class +Savage Beast 2.3 plugin
Hi, i am using Savage Beast 2.3 plugin for the forum and i got and error undefined method `has_many'' for Object:Class C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb: 9:in `included'' C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb: 7:in `class_eval'' C:/forum/vendor/plugins/savage-beast/lib/savage_beast/user_init.rb: 7:in `included'' C:/forum/app/models/user.rb:2:in `include'' C:/forum/app/models/user.rb:2 C:/forum/app/controllers/users_controller.rb:16:in `create'' please help me to resolve this problem....
2009 Sep 28
5
Multi-databases support
Hi, While I was hacking ovirt-server, I have found that it's currently restricted to Postgres DB. Even if I like postgres for serious work on a server, I really prefer to hack/dev locally on a Sqlite or MySQL DB. I have googled on rails in order to find a good answer for the "foreign key problem" which forces OVirt to stay on pg. I have found a plugin on this particular
2013 Oct 25
6
Migrate postgresql database to uuid
Hi all, I am using rails 3.1 and ruby 1.9.3,Now i want to use uuid concept in rails 3 for existing data so i did like :- create_table :posts, :id => false do |t| t.string :uuid, :limit => 36, :primary => true end ActiveRecord::Base.class_eval do # old rails versions set_primary_key ''uuid'' before_create :generate_uuid def generate_uuid self.id = UUIDTools::UUID.random_create.to_s end end This is working for new data,now i want to migrate existing data with relation.for uuid they are using datatype as string,in pos...
2007 Jan 19
3
How to have 'o' == 'ö'
Greetings, (using acts_as_ferret) So I have a book title "M?ngrel ?Horsemen?" in my index. Searching for "M?ngrel" retrieves the document. But I would like searching for "Mongrel" to also retrieve the document. Which it does not currently. Anyone have any good solutions to this problem? I suppose I could filter the documents and queries first which something
2006 Jul 26
4
Execute code when an inheritance happens, or disabling STI
I am trying to inherit from a ActiveRecord class defined in a plugin. The problem is that ActiveRecord thinks I am doing an STI and is looking up a table that doesn''t exist. Currently, I have a method in the parent class that looks like this: def self.fix_table_name class_eval do set_table_name(Inflector.tableize(self.to_s)) end end The problem is that this method has to be manually called from each inheriting class. There must be a better way to execute this code. Any ideas? -- Posted via http://www.ruby-forum.com/.
2006 Feb 14
10
acts_as_versioned and getting authors
Hey guys and gals, I have the following object that has acts_as_versioned: class Note < ActiveRecord::Base acts_as_versioned belongs_to :user end The schema for my notes table is as follows: create_table :notes, :force => true do |t| t.column :id, :integer t.column :noteshare_id, :integer t.column :user_id, :integer t.column :title, :string
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