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
Category Archives: Rails
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 – Show Flash Message
The flash message is useful for notifying user. Rails 3 allows simple manipulation of the flash message.
1. Add the flash message in app/views/layouts/application.html.erb Continue reading Rails – Show Flash Message
Rails – Devise User Sign In for RSpec
Last time we should you how to create the mock user using the Factory Girl ♥ Rails gem.
Rails – Create Mock Data for RSpec
Recalled that spec file. Continue reading Rails – Devise User Sign In for RSpec
Rails – Create Mock Data for RSpec
When running the test cases, most likely we need some mock data to test the functionality of our code. The factory_girl_rails gem is useful for creating mock data for testing purpose. Continue reading Rails – Create Mock Data for RSpec
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
Rails – Customize Devise’s Views
Last time we have talked about how to install Devise in Rails.
Rails – Setup Devise for Rails
Now we want to customize the Devise’s views.
Overriding the default Devise’s views is simple and straight forward, what we need to do is just generate those views in our app/views folder by the following single command. Continue reading Rails – Customize Devise’s Views
Rails – Setup Devise for Rails
Devise is a Rails gem which could help you managing the authentication of your Rails project.
This post followed the steps in Railscasts – Introducing Devise. I made my own notes here such that i don’t need to watch the tutorial again. It is highly recommended to go through the video. Continue reading Rails – Setup Devise for Rails
Rails – Modify Application Name
If you want to change the application name of Rails 3, modify the following files.
- config.ru
- Rakefile
- config/application.rb
- config/environment.rb
- config/environments/development.rb
- config/environments/test.rb
- config/routes.rb
- config/initializers/secret_token.rb
- config/initializers/session_store.rb
Done =)
Reference: How to rename a Rails 3 Application