search for: instance_variable_set

Displaying 20 results from an estimated 37 matches for "instance_variable_set".

Did you mean: instance_variable_get
2006 Jul 04
7
inverse of eval() ?
I''m trying to figure out how to turn a string into an object. Can anyone point me? Here''s some background. Here''s the part of what I''m trying to do that works. ------------------------------------- @ford = [''mustang'', ''pinto''] make = ''@ford'' puts eval(make) --> produces mustang pinto
2008 May 07
1
Assigning to the foreign key on a belongs_to association
...ff --git a/activerecord/lib/active_record/associations.rb b/ activerecord/lib/active_record/associations.rb index 0809b27..7135e50 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1094,6 +1094,13 @@ module ActiveRecord instance_variable_set(ivar, new_value.nil? ? nil : association) end + if association_proxy_class == BelongsToAssociation + define_method("#{reflection.primary_key_name}=") do | target_id| + instance_variable_set(ivar, nil) + self["#{reflection.prim...
2006 Sep 20
0
boy, that mongrel_upload_progress handler sucks!
...arams) return unless params[''PATH_INFO''] == @path_info && params[Mongrel::Const::REQUEST_METHOD] == ''POST'' && upload_id = Mongrel::HttpRequest.query_parse(params[''QUERY_STRING''])[''upload_id''] instance_variable_set(checked_var(upload_id), nil) Mongrel::Uploads.finish(upload_id) end end I''m going to work this into svn. But, there''s another issue. Using instance vars means you''re basically adding random instance vars into the class. They''re set to nil on finish, but...
2005 Apr 23
2
[Tip] Introspection to determine if a column may be null
...tion_schema.columns where table_name=''#{table_name}'' and column_name=''#{col.name}''" col_is_required = nil log(sql, nil, @connection) { |connection| col_is_required = connection.query(sql)[0][0].downcase != ''yes'' } col.instance_variable_set( :@required, col_is_required ) } end end -- (-, /\ \/ / /\/
2007 Jun 08
1
JRuby and tests
Using JRuby / ActiveRecord-JDBC / PostgreSQL 8.1 I get jruby --command rake test (in /Users/stevel/Publisher) rake aborted! Task not supported by ''jdbc'' Is it really the case that testing is not yet supported by ActiveRecord-JDBC or am I missing something obvious? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2009 Apr 19
19
Controller spec: testing that scope is set
In a Rails controller I set the scope on a model class in an around filter. I have defined expectations on the model classes, and ideally, I would add a further expectation for the scope. Is this already possible in some way? How would I go about adding support a scope expectation? Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/
2009 Feb 03
3
ROXML from_xml not returning an object instance...
Hello, I have two ActiveRecord classes. One is Route the other is Waypoints. I have constructed an XML representation so I can use AJAX to create a Route with all waypoints in a single create call to RouteController. When I call Route.from_xml(xmlString) it is not returning an object - it''s leaving the object (@route) nil, but not erroring. Any ideas? Here''s some code:
2009 Mar 22
5
How does view know about instance vars set in controller?
Hi, I know that the AWDWR says to believe in magic and to not spend Xmas with people asking this question, but really how does it work under the hood? I was looking at the source code of crummy, and it seems that instance_variable_set and instance_variable_get may be part of the answer. Is there some resource on that or do I have to dive into Rails code? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups &quot...
2006 Jan 03
1
RequireResourceHelper for JS and CSS
...(:javascript) @javascripts.uniq.inject("") do |buffer, js| buffer << javascript_include_tag(js) + "\n " end end def require_resource(type, name) variable = type.to_s.pluralize array = instance_variable_get("@#{variable}") instance_variable_set("@#{variable}", (array || []) | [name]) end def require_javascript(script) require_resource(:javascript, script) end def require_stylesheet(sheet) require_resource(:stylesheet, sheet) end end Duane Johnson (canadaduane) http://blog.inquirylabs.com/ ----------...
2006 Aug 05
5
RESTful Nesting issue
I?m having a strange issue with nested routes though, and was wondering if anyone could shed some light on this? If I have: map.resources :users do |users| users.resources :items end When I try to call <%= link_to_remote ''Delete'', :url => item_url(@item), :with => "''_method=delete''", :confirm => ''Are you sure?''
2006 Mar 04
5
has_many and belongs_to example?
Hi! If i have 2 tables i.e. product and images and product has_many images, image belongs_to product - how to create _form.rhtml, new/create and edit/update methods in product controller, so in a single form i can add one product and MANY (let''s assume for now that this number is fixed) images for this product? Pleeeeease help me :) -- Posted via http://www.ruby-forum.com/.
2006 Apr 22
6
STI and type tables?
So by default to get STI, I would have something like: create_table :items do |t| t.column "type", :string t.column "title", :string end But if I want to store those type values in a separate table, such that I have ... create_table :items do |t| t.column "item_type_id", :string t.column "title", :string
2006 Jan 19
2
Easy way to handle form input without a model class?
I have a couple forms that I''d like to be able to validate and automatically populate, but it shouldn''t be based on AR. In fact I often have a bunch of small forms that I can''t really justify writing a whole new model class for anyway. I''d like to validate the form input, and then use rails helpers to automatically populate the form if validations fail.
2007 May 29
4
cache everything but...
I saw this older post when searching for information: On Feb 16, 5:10 pm, Ingo Weiss <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > withfragmentcachingonecancacheparts of a page. However, more often > than not what I would need is the exact opposite approach. I would like > to be able to use action cashing and have a mechanism for telling Rails > to
2006 Mar 12
2
Find all the methods on a object in an irb session?
How can I find all the methods on an object from withing irb? Thanks, Joe
2005 Dec 30
1
metaprogramming in controller: accessing instance variables
Hi all, I''m trying to move a bunch of methods out of a controller into a library that I can include and call a class method to have it dynamically add a bunch of methods to the controller. The goal is to just add to each controller: include UIEnhancements::SubList sub_list ''Note'', ''incomplete'' and have the sub_list method create all the methods
2007 Aug 11
0
nested layouts
hi, I''m using a helper like in nested-layouts plugin as follows def inside_layout(layout, &block) layout = layout.include?(''/'') ? layout : "layouts/#{layout}" @template.instance_variable_set(''@content_for_layout'', capture (&block)) concat( @template.render( :file => layout, :user_full_path => true ), block.binding ) end used like this: views/layouts/bar.html.erb: <% inside_layout ''foo'' do -%> ...stuf...
2007 Jul 09
0
Is it bad to use a shared example in rspec_helper.rb?
...ec_helper in a rails project for controller tests? I have in my spec_helper.rb describe "an authenticated request", :shared => true do before( :each ) do @u = mock_model( User ) mock_login( @u ) end def mock_login( user ) session[:user] = user controller.send( :instance_variable_set, :@current_user, user ) controller.stub!( :current_user ).and_return( user ) end end which I then share in my relevant controller tests with it_should_behave_like "an authenticated request" Is this bad? -------------- next part -------------- An HTML attachment was scrubbed.....
2007 Feb 08
1
mongrel cluster and local gems loading problem
...red" (because rubygem Gem.path method caches the path on the first use, which is done by mongrel_rails). To make this work, I had come to this hack: ENV[''GEM_PATH''] = File.expand_path(''~/.gem'') require ''rubygems''; Gem.clear_paths; Gem.instance_variable_set(:@searcher, nil) Which clears the internal cache used by rubygems, and forces it to re-read the GEM_PATH env. variable. But I don''t fell comfortable using it... is there a better way to do this? Like, setting the GEM_PATH from the mongrel cluster config file? Best regards, Rui Lopes...
2010 Aug 12
2
wxRichTextCtrl not Working through wxFormBuilder
I''ve used wxFormBuilder to put a wxRichTextCtrl on my form. After doing this, I run xrcise and try to use the control. The variable for the rich text control is a FixNum. On examination, I saw that the class name in the xrc file is "unknown". Is there no way to use this control without manually laying out the controls - or writing this routine in C++? Does anyone know a