RailsCasts Pro episodes are now free!

Learn more or hide this

Jaime Iniesta's Profile

GitHub User: jaimeiniesta

Site: http://www.jaimeiniesta.com

Comments by Jaime Iniesta

Avatar

Thanks for this excellent railscast, Ryan!

pg_search is great, but setting up indexes and triggers can be tricky. Here's how I set it up, works great (like, 40 ms to search on 200K documents)

https://github.com/Casecommons/pg_search/issues/15#issuecomment-21884006

Avatar

Thanks for another great screencast, Ryan.

Something to keep in mind: the /announcements/:id/hide route will fail with a 500 error if visited directly, as there is no request.referer in that case. This should be checked by the controller and redirect to a default url in that case, or maybe render a 404.

Also, I would add rel="nofollow" to the link, so that spider bots don't follow it.

Avatar

I was also finding problems making Pigments work from within redcarpet. I finally opted for Coderay, as on the original version of this railscasts, here's what I did:

How to colorize code in comments using CodeRay

Avatar

Answering myself, there is an easy way, you just need to override confirmation_required? like this:

class User < ActiveRecord::Base
  def confirmation_required?
    super && email.present?
  end
end

Devise is great :)

Avatar

Thanks for another great episode, Ryan!

How would you do it if you also wanted to use the :confirmable module in Devise? This sends an email for confirmation on user creation, but it fails in the scenario where you don't require an email address.

Is there an easy way of not requiring email and only confirm it if provided?

Avatar

Something to keep in mind when trying Celluloid on Heroku is memory usage.

Heroku will restart your processes if they use too much memory, so you'll want to experiment to find the number of threads you can run, that depends on your work load.

I found this when working on heroku with girl_friday. It worked, but it crashed frequently due to memory limits.

Avatar

I had the same problem, in my case I had to reinstall the pg gem and everything worked fine. This post was useful:

http://tammersaleh.com/posts/installing-postgresql-for-rails-3-1-on-lion

Avatar

The problem with the default is it will accept any mime type, as it will only check the boolean and not the string:

@default || req.headers['Accept'].include?("application/vnd.example.v#{@version}")

I mean, if we're expecting "application/vnd.github.v1", it will also accept "application/vnd.twitter.v1"

Avatar

Moving the sass-rails gem out of the :assets group as @autodidakto says below lets me run the db migrations, but I'm still having the rake assets:precompile issues on heroku cedar.

There is an open issue for that

Avatar

Thanks Ryan!

Another alternative for faking Time is Delorean. It's quite similar to Timecop, although it does not offer the freeze capabilities. Check it out, its code is really minimal and beautiful!

https://github.com/bebanjo/delorean