Rails 4 has asset digest issues
For those upgrading to OR using Rails 4 Please have a look at the github thread https://github.com/rails/sprockets-rails/issues/49 Proposed solution : https://github.com/alexspeller/non-stupid-digest-assets OR https://github.com/rails/sprockets-rails/issues/49#issuecomment-25946196
pagekite.net - fast and reliable localhost tunneling solution
You may have came across a situation where you need to share your local app to clients (in other words your Rails app running on your local server port 3000). You may have came across a situation where you need to share your local server. So in such cases a widely used tool is localtunnel But it has a limitation with consistent url as it generates a random URL for every new instance. Pagekite suffices this need and gives a consistent URL for one server bind to a port. PageKite makes local websites or SSH servers publicly accessible Getting Started
Backing up Databases and Directories
Backup your Database OR any of your personal stuff like directories with [backup][1] Backup's Components Archives and Databases Compressors and Encryptors Storages Syncers Notifiers Its a handy backup tool with plenty of storage options (for example: S3, Dropbox, FTP, SCP and many more) For installation(Dependencies should be installed if you are working with shell environment) gem install backup backup dependencies --install net-ssh backup dependencies --install net-scp backup dependencies --install excon backup dependencies --install fog Now execute the @backup generate@ command backup generate:model -t backup [-c ] --archives \ --storages='local,s3' --compressors='gzip' --notifiers='mail,twitter' This will create
Performance Optimization
In a Ruby On Rails applications where we follow convention over configuration, we might get hit by a slow server response, that would eventually cost users shy away from application. There are many ways of how you can boost performance of Ruby On Rails applications. Focusing on approach depending on the application structure, size of the database and traffic intensity, our performance optimization can be carried out. Rules for Performance Optimization Measure Optimize What is slow Test and Isolate changes Primary areas to think about where we can improve performance are Views and ActiveRecord Queries PS Note : Will be continued.
ZEUS test_environment
Just found that I couldn't do zeus c test for a test environment console Here's a workaround or small hack to do this Steps On your console do zeus init This will create two files zeus.json custom_plan.rb Add this snippet to your custom_plan.rb and define the tasks for Zeus. Mine looks like this: require 'zeus/rails' class CustomPlan Edit zeus.json to include only the tasks for which you’ll use Zeus. Mine looks like this: { "command": "ruby -rubygems -r./custom_plan -eZeus.go", "plan": { "boot": { "default_bundle": { "development_environment": { "prerake": {"rake": []}, "runner": ["r"], "console"
Test Unit Macros.
While writing functional test cases, we might need a common utility to be used through our test cases. These utility is generally recognized as "Macros" and more specifically as "Controller Macros". With Rspec we can easily configure such Macros, as Rspec specifically provide a RSpec.configure block to define all our utility and support classes/modules used throughout our test suit. The RSpec.configure block looks like this. RSpec.configure do config.extend(AuthenticateMacro) end With Test::Unit which is a default testing tool provided by rials and its much more liter than Rspec, we can't
Easy filters for Devise controllers
Here's a way to add filters to your controllers without subclassing the Devise controllers. For example, I have a prepare_something method that I want to apply as a before_filter to all of the Devise controller actions. First, create a module in config/initializers/devise_filters.rb where we’ll implement a method to add all the filters to Devise that we want. We also need to make sure this module calls this method upon initialization so that our filters get added upon startup (this is important for the production environment). # Put this somewhere it will get auto-loaded, like
Serving Private Content From AWS-CloudFront
Purpose Restrict access to data distributed via Internet, it is important to restrict access to documents, business data, media streams, or content intended for the legitimate users. You can use CloudFront private distributions to restrict access to data in Amazon S3 buckets. How to Restrict access to these private content ? By using signed URL one can restrict access to these private contents. Signing a URL is the process of creating an RSA digital signature using an RSA key and a policy statement. AWS provides a public-key and private-key(called as key-pair) to its users. AWS keeps the public key, and
Amazon CloudFront
What is CloudFront ? CloudFront is a web service that speeds up distribution of your static and dynamic web content, for example, .html, .css, .php, and image files, to end users. CloudFront actually is a CDN [more on CDN][1] How it works ? CloudFront delivers your content through a worldwide network of edge locations. When an end user requests content that you're serving with CloudFront, the user is routed to the edge location that provides the lowest latency, so content is delivered with the best possible performance. If the content is already in that edge location, CloudFront delivers it immediately. If
WARNING : Cant Verify token authenticity.
It is a warning that may appear in your log. Primary reason for this warning is CSRF_meta_tag is missing in your layout. OR Following are some other solutions to get rid of this WARNING. Add CSRF token in ajax request header using xhr. (Highly recommended) Override the method : verified_request (Recommended to override the check for JSON request only). Skip the method call verify_authenticity_token. Change POST to GET (Token verification is done for requests other than GET)