Category Archives: Rails

Rails – Debug Your Application in View

During development we always need to print the objects in views for debug. In Rails, there are two ways you can print the Ruby objects. Continue reading Rails – Debug Your Application in View

Rails – Redirect Previous Page After Devise Sign In

By default, Devise will redirect you to the root path after sign in. but sometimes we would like to redirect to the previous page where the anonymous user wanna access. This can be done by the following. Continue reading Rails – Redirect Previous Page After Devise Sign In

Rails – RSpec Test with Devise

According to the documentation in the Devise home page, we can use the following before_filter to control the user access on specific controller functions.

before_filter :authenticate_user!

 

But when i try to test the controller function in RSpec, i got the following error.
Failure/Error: post :create
undefined method `authenticate!’ for nil:NilClass
Continue reading Rails – RSpec Test with Devise

Rails – Add Custom Fields to Devise User Model

Previous related posts:

By default, the users table in Devise only contains the email and password fields in user profile. Most likely we need to add our custom fields such that we can store more user information. The following steps show you how to add a username field in the users model. Continue reading Rails – Add Custom Fields to Devise User Model