Change URL and enable browser back button with AJAX

We all are aware that clicking any link that sends AJAX call doesn't change the url with the href of the link clicked. As the browsers history is not also updated, back button too will not work. One alternative is to use PJAX that updates the url and browsers history thus enabling back button. What if we don't what to use PJAX? There is way of manipulate browsers history to reflect updated url and enable back button. This technique is used by Github in its file browser. When we click on folder in Github repo, the page updates via AJAX

Devise and integrating Omniauth with Devise

Devise is an authentication solution for Rails. It makes use of Warden which is Rack based authentication framework. Steps to integrate Devise: Include devise gem in your gemfile. gem "devise" Run bundle install to install it. Generally, all the login related details are kept in User model. You are free to use any model name as per your needs. Here User model is used as an example. Generate User model using devise generator command: rails generate devise User Above command will generate user model, migration for user and adds devise routes in _routes.rb_. Now you are all set to

Enabling encryption on S3

Files uploaded on S3 are not encrypted. To make them secure, we either need to encrypt the file at client's end then upload or configure S3 settings to encrypt the files after upload. i.e Server Side Encryption. Amazon S3 Server Side Encryption (SSE) employs AES-256, an encryption standard that provides a considerably high level of protection. To allow SSE for S3, just include following code in headers while uploading file: 'x-amz-server-side-encryption' => 'AES256' To check, login to S3 and check properties of the file uploaded. The "Server Side Encryption" option under Details tab should show AES-256 radio

Stub HTTP requests in Rspec

In rspec, we need to make http call for our test to pass. In this case, we are actually making http request which is not a best practice while we are executing tests. The best way is to fake http request with the actual expected response without making actually going to that url. For faking http request in ruby, we have couple of gems namely FakeWeb and WebMock. FakeWeb: Usage: Include 'fakeweb' in your Gemfile under test group only. require it in spec helper. use it in specs Syntax: FakeWeb.register_uri(method, url, :body => "response text, html,

Auto-run background jobs with Procfile and Foreman

Following are the links that explains Procfile and Foreman. [Foreman Manual][1] [Introducing Foreman][2] [Declaring and Scaling Process Types with Procfile][3] [1]: https://devcenter.heroku.com/articles/procfile#developing_locally_with_foreman [2]: http://blog.daviddollar.org/2011/05/06/introducing-foreman.html [3]: https://devcenter.heroku.com/articles/procfile#scaling_a_process_type

Scheduling resque-jobs

If you want to run a resque job after every regular interval of time, just like cron jobs, there is a gem "resque-scheduler" which will do it easily. [More on this gem][1] [1]: https://github.com/bvandenbos/resque-scheduler#readme