RailsCasts Pro episodes are now free!

Learn more or hide this

Alex Blakemore's Profile

GitHub User: alexblakemore

Comments by Alex Blakemore


To anyone proposing solutions for improving access controls, (or doing updated rairscasts)

please include a simple DRY way for seeds.rb and test fixtures/factories to operate with minimal interference. For example, my customer requires several read-only lookup tables in the database . Even though they are read-only in steady state, i'm forced to list each column name with attr_accessible in each model, just to have a simple seeds.rb file. Would be helpful to have a way to turn off all the controls in special cases like that, without having to list each attribute name for each model.


Can anyone explain why the class method Products::to_csv is successfully getting called from the controller code below?

@products = Product.order(:name)
send_data @products.to_csv

@products is not the Products class object, but the method gets called. Then inside to_csv, it calls the all method. Does that repeat the query? or does it somehow apply all to the array @products?

To make it even more confusing, if I repeat this setup with an arbitrary method name instead of to_csv inside the rails console, I get NoMethodError. What's going on?


The jruby-rack-worker gem comes to the rescue: http://github.com/kares/jruby-rack-worker. It lets you still use delayed_job to schedule jobs, but provides a different way to kickoff worker processes that is more friendly to JRuby and also works on a windows tomcat server. I'm not advocating deploying on windows, but if you're forced to do that for some reason and you also need to use JRuby -- take a look at jruby-rack-worker.


DelayedJob doesn't seem to work with JRuby unfortunately, at least not on windows -- as best I can tell. It will queue jobs, but starting a background job fails.