I didn’t realize that Cucumber was so versatile…
If you are writing you own mix-in modules in Rails3 and haven’t taken a look at ActiveSupport::Concern yet, I recommend checking out this blog posting for an outline of why you should be using it:
If you are already using this then good for you and you can continue on.
Here’s a little “stumbling block” with ActiveSupport::Concern that I found the other day that I wanted to share with people. If you have the following code:
module Bar extend ActiveSupport::Concern included do attr_accessor :baz end def baz "Baz" end end class Foo include Bar end puts Foo.new.baz
You might expect the puts to write out “Baz” but it writes out nil instead. Why is that? It has to do with the order in which ActiveSupport::Concern tacks all of the module code into the class including the module. If you
change “attr_accessor” to attr_writer” all works as planned.
So yes you might be saying “why do you have attr_accessor when you define a getter method for baz?” and my response is “because it worked ok before I factored the code out into a module for reuse”.
The other day I was looking to test some rescue_from functionality in a subclass of ApplicationController and found an easy way to set this up, the controller() method.
Note: Testing of ApplicationController subclasses is a new addition and not available in a released beta of rspec-rails2 as of the writing of this post.
Ask for Help
- Double-entry/ledger based accounting in Rails (i.e. Quickbooks in Rails for free)
Ideally would be tied in with user/role system where each accounting entry would be tied to a user, but also reconciled against a master account.
Recommendations? Latest and greatest?
- Error message when opening Rubymine “Invalid Git Root”
This is likely because the project included a submodule that wasn’t configured correctly, fix this in under Rubymine’s version control preferences.
- Test 404 handling (e.g.
rescue_from ActiveRecord::RecordNotFound, :with => :render_record_not_found) with Cucumber by temporarily setting
ActionController::Base.allow_rescue = true. This is usually set to
JSON.pretty_generatehates Rails 3
- Use window.postMessage to communicate between IFrames in a standard way
This should work in most modern browsers. Follow the Mozilla docs, NOT the various blog posts about this.