Deleting all records in a Rails project

During the initial phase of development of a Rails application I don’t use migrations as migrations but as table definitions. Until I deploy I feel free to modify the migration files as much as I want and I have one per table. The downside of that is that the...

undefined method `authenticate?'

If you are getting this error: ActionView::Template::Error: undefined method `authenticate?’ for nil:NilClass in your call to Devise’s user_signed_in? or similar, you probably forgot to add this: class ActionController::TestCase include Devise::TestHelpers...

I suddenly love my… ISP

People, including me, tend to make a big deal of bad stuff and not of good stuff, so I sometimes try to do the oposite. Recently my internet connection was slow, very slow. Several weeks passed and I’ve got really angry so I did complaint, expecting to be...

Better assert difference?

Rails come with some awesome assertion methods for writing tests: assert_difference(“User.count”, +1) do create_a_user end That asserts that the count of user was incremented by one. The plus sign is not needed, that’s just an integer, I add it to...

Redirect to SSL in Rails applications

I’ve looked at the various ssl_requirement repositories out there. I concluded the most modern and maintained version is yardstick’s which is released as a gem called sslrequirement, but I’ve failed to use it properly. So I just did it by hand....