Displaying 18 results from an estimated 18 matches for "const_set".
Did you mean:
const_get
2007 Mar 19
3
controller_name with dynamic controllers
.../2006/07/crud-and-shared-controllers.html
Now, in my spec, I would like to create a controller which inherits
from the generic CRUDController, without actually creating the
controller. This controller is *only* for testing.
How can I do this? I can''t do something like this:
Object.const_set("MyCrudController", Class.new(CRUDController))
because the method "controller_name" will complain of setting the
constant twice.
Any ideas?
Best,
Scott Taylor
2007 Jun 08
4
Mocha 0.5 released
* Hamcrest-style parameter matchers
* Values returned and exceptions raised on consecutive invocations
* Yields on consecutive invocations
* Multiple yields on single invocation
* Invocation dispatch fixed
* Deprecated returning result of a Proc
--
James.
http://blog.floehopper.org
2006 Jan 11
1
logger in my classes
...alization''
just after the line
require File.join(File.dirname(__FILE__), ''boot'')
I tried many ways to reuse the logger class. The cleaner way seemed to
be based on Object::RAILS_DEFAULT_LOGGER that is defined in
/railties/lib/initializer.rb:
silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger }
But all I get is an uninitialized constant :(
Please tell me the right way to reuse logger.
--
Jean-Christophe Michel
2010 Jul 25
0
You can't set a constant with namespace in the initializers?
...e_controller.rb
...
admin/posts_controller.rb
admin/pages_controller.rb
The ''Admin'' will automatically become a Module constant (I know it
from the console: ''puts Admin => Module'');
And in my initializers, ther is a init.rb which has codes like this:
Object.const_set(''A'', ''a'')
Object::Admin.const_set(''B'', ''b)
Then I run the console:
>> puts Object::A
"a" #just fine
=> nil
>> puts Object::Admin::B
NameError: uninitialized constant Admin::B # What''s...
2007 Mar 19
0
action_web_services error with rspec_on_rails
...39;m not using webservices at all: So can someone clue me into what
is going on or point me in the right direction? Here are the two specs:
#spec one
require File.dirname(__FILE__) + ''/../spec_helper''
def one_join_model_setup
unless defined? CommentController
Object.const_set("CommentController", Class.new
(CrudResourceController))
end
#CommentController.class_eval { join_models :post }
controller_name ''comment''
end
context "join_model" do
one_join_model_setup
end
## spec two
require File.dirname(__FILE__) + '...
2008 Mar 24
4
Doesnt show log on command prompt
I have latest version of mongrel installed.
But when I run ''ruby script/server'' it starts the server and shows
nothing else, like development log it used to show on my previous dev
machine.
Any idea?
--
Posted via http://www.ruby-forum.com/.
2006 Aug 01
4
class def error when serving "stand-alone" rhtml files
I''m attempting to set up a rails app so that I can add rhtml files
without having to create controllers for each one. I want a simple
solution to serving static-like rhtml files as well as those with a
little logic. The solution I found is this one:
I added the following controller
static_controller.rb
#####################
class StaticController < ApplicationController
end
I
2006 Jan 11
0
Connection problem with a generic-runtime-built ActiveRecord::Base
...:database => dbName,
:username => user,
:password => pwd)
end
def self.closeConnection()
return ActiveRecord::Base.remove_connection()
end
def self.buildNewTableClass(className, tableName)
genClass = Class.new(GenActRec)
const_set("#{className.to_s}", genClass)
genClass.set_table_name tableName
genClass.reset_column_information()
return genClass
end
# read table Column names
def readTableColumnNames
return self.class.column_names()
end
end
this how I use it:
class GentestController &...
2009 Jan 29
0
How to get rid of an ActiveRecord warning "already initialized constant"
I need to get a proxy class for a specific AR validation
I reuse a piece of code (from Globalize), where it''s set as a
constant :
module Globalize
module Model
module ActiveRecord
class << self
def create_proxy_class(klass)
Object.const_set "#{klass.name}Translation", Class.new
(::ActiveRecord::Base){..}
..
end
so in my validation module, I can write :
translation_class = Globalize::Model::ActiveRecord.create_proxy_class
(self.class)
no problem when executing it...
but in my model unit tests, I execute it many times, and...
2014 Feb 22
0
Validates inclusion of include fails at plugin.
...e_const, :TYPES)
base._validators[:my_type].reject!{ |validator| validator if
validator.is_a? ActiveModel::Validations::InclusionValidator }
TYPES = { "type1" => 1 , "type2" => 2, "type3" => 3,"type4" => 4,
"type5" => 5 }.freeze
base.const_set('TYPES',TYPES)
base.class_eval do
validates_inclusion_of :my_type, :in => TYPES.keys
end
----------------------------------------
In my View or Console, The MyModel::TYPES gives me the patched hash, But
saving the patched model with the new types failes. With the error "is
not...
2006 Sep 04
8
ActiveRecord-JDBC is coming along
The ActiveRecord-JDBC adapter is rapidly maturing these days. I got the full
set of AWDwR2 migrations to run with it against MySQL last night, and Ola
Bini has gotten migrations working well against Oracle and Firebird. We also
have SQL Server support running most of our test cases (under non-Windows
environments too!) and have started adding support for Derby and HSQLDB
(Java-based DBs). Things
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 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
2008 Oct 14
3
Server settings for BackgrounDRB?
I have backgroundrb working locally and everything''s fine. However, i
can''t get it running on our server.
I read a blog post by David Burger about backgroundrb
(http://david-burger.blogspot.com/2008/04/backgroundrb-rails-notes.html#comment-form)
and it says that you set up your backgroundrb.yml file with a different
section for each environment you want to use. Mine looks like
2006 Jul 16
17
AWDWR question
In an early section on Action View, showing code being put directly
into the rhtml file:
<% require ''date''
DAY_NAMES = %w{ Sunday Monday Tuesday Wednesday Thursday Friday Saturday }
today = Date.today %>
<h1>Hello, Dave</h1>
<p>
It''s <%= DAY_NAMES[today.wday] %>.
Tomorrow is <%= DAY_NAMES[(today + 1).wday %>.
</p>
I get this
2006 Aug 24
3
Mousehole stuff
Hey everyone,
I''m using mousehole for the first time today (love the artwork, btw) and I
seem to be having problems with Camping and Markaby. When I go to the Apps
page I get:
Camping Problem! MouseHole::Controllers::RApps.GET TypeError
/Users/tzaharia/Sites/mouseHole/lib/mouseHole/views.rb:78:in `+'': can''t
convert String into Array:bla bla bla...
The line in question
2006 Nov 14
11
RESTful mixin, mixin repo?
Hi,
I just put together a little mixin to provide pseudo-RESTful services
in camping apps. Basically, it looks for a hidden _verb field in form
posts, and sets the @method to the supplied value (e.g. put or delete
- which browsers don''t support). This lets you define put and delete
methods in your controllers. Groovy.
Code:
http://pastie.caboo.se/22613
Is there any permanent repo of
2007 Mar 22
0
[916] branches/wxruby2/wxwidgets_282: More Wx::AUI classes, event hooks and sample
...ID_InactiveCaptionColour
+ ID_InactiveCaptionGradientColour
+ ID_InactiveCaptionTextColour
+ ID_ActiveCaptionColour
+ ID_ActiveCaptionGradientColour
+ ID_ActiveCaptionTextColour
+ ID_BorderColour
+ ID_GripperColour ]
+
+ consts.each_with_index do | c, i |
+ const_set(c, 1001 + i)
+ end
+
+ def initialize(parent, frame)
+ super(parent, Wx::ID_ANY)
+ @frame = frame
+ @base_bmp = create_colour_bitmap(Wx::BLACK)
+
+ # set up some spin ctrls for integer variables
+ @border_size, s1 = make_metric_spin_ctrl( ID_PaneBorderSize,
+...