Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Ches Martin's Profile

GitHub User: ches

Site: http://chesmart.in

Comments by Ches Martin

Avatar

Thanks for taking the time to make these improvements, and especially to give the detailed explanatory commit messages Karel, they're really helpful.

Avatar

For anyone still referencing this, current ActiveRecord versions now have a reset_counters convenience class method that will automatically execute a count query for you. Also, please do use find_each instead of find(:all).each :-)

I'm not wild about using migrations to modify data personally, but if you insist:

ruby
def self.up
  add_column :projects, :tasks_count, :integer, :default => 0

  Project.reset_column_information
  Project.select(:id).find_each do |p|
    Project.reset_counters p.id, :tasks
  end
end

def self.down
  remove_column :projects, :tasks_count
end
Avatar

You can easily have the best of both worlds -- I rather like Foreman's log presentation for the various processes, so I actually run Guard at the end of a Procfile, and use an environment variable to limit groups if I wish:

sh
guard: bundle exec guard start $([ -n "$GUARDS" ] && echo "-g $GUARDS")

This way you could also employ guard-process as you mention for things that should restart when code is changed.

If you use your Procfile for production -- either on Heroku or to generate upstart/init files at deploy -- you'll want a separate Procfile for including Guard in development. I'm too lazy to type foreman -f config/dev/Procfile all the time so I wrap that in a rake dev task.

Avatar

At just about the time you asked this, the plugin author implemented the propertyToSearch configuration option for this :-)

Avatar

I added a dirty instance_eval hack to make Hirb.disable/enable work in-session:

https://gist.github.com/1177892

cldwalker is probably opinionated about Ripl, but I'll ask if he'll accept a patch to Hirb for built-in Pry support.

Edit: Just found this issue where he indeed says he doesn't want to support more shells in the gem itself (and you guys originally shared this .pryrc snippet =]).

Avatar

Thank you! I took Pry for a spin several weeks ago but didn't take the time to fully explore getting Hirb working so I haven't been using it for Rails' console. I think I will now :-)

Avatar

Small note: from the looks of the jQuery API docs and source, it doesn't appear that jQuery.support.localStorage actually works -- they note that the feature detection is mostly aimed at a small set of features needed for jQuery core and plugins.

Modernizr is a nice straightforward solution for simple yet pretty comprehensive feature detection that I'm finding very handy for graceful HTML5 degradation:

http://www.modernizr.com/