similar to: What does Reloadable mean in rails source code?

Displaying 20 results from an estimated 2000 matches similar to: "What does Reloadable mean in rails source code?"

2006 Mar 02
3
reloadable classes for other base classes than the built-ins
I''m working on the plugin for RBatis and a new little thing I''m toying around with called ActiveMessaging (sorry, David I stole the name from you from the TW AwayDay ;-)). Anyway, in both these applications I want to be able to have reloadable classes that don''t extend any of the standard built in ones. So, I don''t mean to offend the Eminent Core Members by
2012 Sep 11
1
define_method vs module_eval
Rails code: Accessors.send :define_method, :"default_#{name}", &block Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1    def #{name}    -ISKimRw02aC5oVgD8gxYQQ@public.gmane.org(:#{name}, [])    end    def #{name}=(value)    value = value.present? ? Array(value) : default_#{name}    _set_detail(:#{name}, value) if value != @details[:#{name}]    end  
2005 Dec 15
3
define_method with parameters
Hi, I''m trying to write a macro which defines methods. One of these should have a parameter, but I can''t get that to work. Something like: define_method("printstuff") do puts "blabla" end works fine. But, how do I use define_method to create something like: def printstuff(the_stuff) puts the_stuff end Thanks in advance.
2007 Sep 30
2
Outputing to the browser, how?
Hello, I''m writting some helper methods to write forms, so I have this working code: class TableFormBuilder < ActionView::Helpers::FormBuilder ["file_field", "password_field", "text_field"].each do |name| define_method(name) do |label, *args| @template.content_tag(:tr, @template.content_tag(:td, @template.content_tag(:label,
2006 Jun 08
3
Macros and stuff
I was looking at my controller code and the edit/create/update/new for each are practically identical. So first I DRY''d the four methods in each controller to just one and then I decided to write a single macro for all my controllers. This is the macro: def self.edit_action_for(model, options = {}) model_class = Object.const_get(model) define_method(:edit) do
2007 Aug 10
3
Different ferret fields for instances of the same model?
Hi all, So far as I know, while using acts_as_ferret, we should add the following declaration in the ActiveRecord model which is going to be indexed: acts_as_ferret({:fields => @@ferrect_fields}) in which @@ferrect_fields is a hash containing all the field to be indexed. This is pretty much for some simple situations. But I got a more complex situation that I want to define the fields to be
2006 Mar 26
4
edge and 1.8.2/1.8.4 issues
I recently upgraded to 1.8.4 to try out mongrel, and so far have been in a kind of hell where I can''t get my app working! Currently running (or trying to run): Ruby version 1.8.4 (i386-mswin32) RubyGems version 0.8.11 Rails version 1.0.0 Active Record version 1.13.2 Action Pack version 1.11.2 Action Web Service version 1.0.0 Action Mailer version 1.1.5 Active Support version
2006 Mar 10
0
WEBrick crashing
ruby 1.8.2 (2004-12-25) [i386-mswin32] latest version of edge rails - patched to make the server work with win32 (http://dev.rubyonrails.org/ticket/4139) On some pages WEBrick is crashing with the following: d:/programming/ruby/lib/ruby/1.8/profiler.rb:27: You have a nil object when you didn''t expect it! (NoMethodError) You might have expected an instance of Array. The error occured
2008 May 07
1
Assigning to the foreign key on a belongs_to association
I''ve encountered what seems like an odd omission in the behaviour of belongs_to associations: if you assign to the foreign key attribute, it doesn''t update the associated object (or mark a previously loaded one as stale) until you explicitly save or reload it. Let''s say we have a Company model, which belongs_to :city : >> torchbox =
2007 Oct 23
3
CheckListBox : delete method bug !
Hi, I''ve practically finished a patch for removing the limitation of CheckListBox (http://rubyforge.org/pipermail/wxruby-development/2007-October/000973.html) but I just discovered a new bug related with this control !! I need to redefine the delete method to take into account the deletion of the associated data. The problem is that if I just redefine this method and simply call super,
2006 Apr 04
1
"uninitialized constant Reloadable" error heads-up
I can''t duplicate this problem on my local machine, but also can''t find any mentions of it on the Gmane archive, so thought I''d just throw in a quick mention in case anyone else comes across it. On Textdrive, using gem rails 1.1, in an app that works fine on my local machine, I get the following error in my production.log: "uninitialized constant
2011 Jan 08
4
Help How to create DSL for conditional validations
Hi All, I am new to Ruby and ROR I were trying to create small DSL for conditional validations valid_with_cond :bypass_validation do if self.addresses > 3 errors[:base] << "Can not have more than 3 addresses". end end By this I wanted to create array of method and call them all in custom validation method. this above code I wanted to do attr_accessor
2007 May 20
9
How to test for exceptions
Hi folks, I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed. Thanks in advance, Blake describe VenuesController, "on update" do before(:each) do @venue = mock("venue")
2006 Mar 03
7
Meta Programming Help
I have the following two methods: def ProductFile::find_images(mode, prod_id) # convert to symbol in case it is not (most commonly it may be a String) mode = mode.to_sym case mode when :all, :first ProductFile::find(mode, :conditions => ["product_id = ? AND file_type LIKE ?", prod_id, "image%"]) end end def ProductFile::find_documents(mode,
2006 Jun 17
5
STI versus Composition...or the headaches of one big table
Guys, I have a relationship between model classes that I believe is best represented by inheritance, but the likelihood that things will change often is driving us to composition instead. So, I have a class called Autos, and subclasses called Suvs, Minis, Mids, Sports, for example. We have been requested to avoid the STI approach to this, because of fear of a quickly growing table with
2006 Jul 24
1
Injecting actions into controllers
Hi, I''m trying to write a plugin that 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
2008 Jun 05
2
how to add a method without coding it directly into app?
i''m missing something here. how would I code this outside the application to be shared with other Camping apps? module Blog::Controllers module AuthenticationHelper def self.included(base) class << base define_method :authenticate do |*a| a.each do |meth| if method_defined?(meth.to_s)
2006 Oct 10
3
Dynamic fields and inheritance
I have a model that allows subclasses to dynamically define fields. The following code is a short test case that illustrates the problem I''m having: class Product < ActiveRecord::Base acts_as_ferret :fields => [:name] serialize :data def self.data_properties (*properties) properties.each do |property| define_method(property) {self.get_property(property)}
2007 May 10
13
Is there a way to do incremental search?
Say the user first enters "ruby" for search and gets 1000 results. Then he can search "rails" just in the 1000 results just returned. The common scenario is some kind of advanced search. User can incrementally add criteria and the program will narrow the results step by step. I know that at least I can use all the criteria as a whole to do the searching, but this is a waste
2007 Dec 04
1
spec''ing shared controller methods
I want to isolate and spec methods that are shared by controllers, and live in application.rb. Whereas I usually also provide examples in individual controllers that use these methods, not necessarily all the edge cases and I''d like to isolate the examples. This is the approach I''m taking (thanks to bryanl for suggestions and http://pastie.caboo.se/123626). WDYT? This