Archive for the ‘RubyOnRails’ Category

Fixing gem error: undefined method `refresh’ for #<Hash:0x14f7c64>

Saturday, February 10th, 2007

After upgrading to Gems 0.9.2 I got this error when I tried any gem command (except for gem list):

ERROR: While executing gem ... (NoMethodError) undefined method `refresh' for #<hash :0x14f7c64>

Deleting /usr/local/lib/ruby/gems/1.8/source_cache fixed this problem for me.

Notes from the RJS Peepcode Screencast

Saturday, February 3rd, 2007

I recently finished watching the RJS Peepcode Screencast and boy does it kick butt. Here’s my notes from watching it:

  • simply helpful plugin generates dom ids based on object’s: @thing.dom_id – more info

  • use link_to_function + rjs in the view to generate js without an ajax call. example: link_to_function "Click Me", update_page {|page| page.alert "No postback!" }

  • call custom js functions with page.call page.call "my_func_name", param, anotherparam, etc

  • consider putting custom js functions that should be globally available in public/javascripts/application.js (this is included by javascript_include_tag :defaults)

  • page.select will fetch things by id or class page.select('#tasks div a').each do |item| page.hide item end

  • use a method name in a string var as a function call page.send 'method_name', param

  • replace/replace_html for outside/inside an element with page.replace_html page.replace_html 'task_totals', @task_totals

  • insert your own custom js into the page with < < page < < "my_js_method()"

    • or - page < < %( my_js_method(); function some_other_func() { ... } )
    • or - page < < render :partial => "update_totals"
  • assign js vars with values from ruby with page.assign page.assign 'task_totals', @task_totals

  • keep users informed of ajax calls during link_to_remote calls with :loading and :complete callbacks link_to_remote "Click Me", :url => tasks_url(:action => 'hello'), :loading => "Element.show('loading_div')", :complete => "Element.hide('loading_div')"

  • use rjs directly in the controller with render :update render :update do |page| page.alert('whatever') end

  • test rjs with ARTS

rails autotest error solved

Saturday, June 24th, 2006

Long story short: I was getting some strange errors when trying to use autotest with a rails app that I’m working on.

Here’s the error I got:

[note: path edited...]/action_web_service/container/action_controller_container.rb:76:in `require_web_service_api’: neither _api or _api found (NameError) [... lots more output ...] /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.2.0/lib/unit_diff.rb:196:in `unit_diff’: undefined method `first’ for nil:NilClass (NoMethodError) from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.2.0/lib/unit_diff.rb:84:in `unit_diff’ from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.2.0/bin/unit_diff:38 from /usr/local/bin/unit_diff:18 # Test::Unit exited without a parseable failure or error message. # You probably have a syntax error in your code. # I’ll retry in 10 seconds

I managed to fix it by rebuilding my entire rails environment using the helpful instructions linked to from the rails site. Thanks Hivelogic!