Friday, May 31, 2013

How to control the order of css file inclusion in Rails 3.2 asset pipeline?

In your application.css remove the require_tree .
Then add the css files one by one in the order you would like it to be included in the html. Like this:

*= require_self
*= require 'form'
*= require 'layout-fix'

and so on. Just leave the require_self as it is. For a detailed explanation: RAILS ASSET PIPELINE HANDLING OF CSS & JS 

Wednesday, May 29, 2013

NoMethodError: undefined method `y' for main:Object

If you want to use the y method to inspect an object in yaml format. Whenever you bring up rails console in development, you can inspect any object.  Just add the following line to your development.rb:

YAML::ENGINE.yamler = 'syck'

How to print text in green in Ruby

text = "This is a test"
irb > print "\033[32m#{text}\033[0m"
This will print the text in green.

NoMethodError: undefined method `buckets' for :AWS::Core::Configuration

Resolution: Use the constructor version of S3 : s3 = AWS::S3.new('your credentials')

Tuesday, May 28, 2013

ignoring config/database.yml

If you already have the config/database.yml file in the repo and you want to ignore it. Follow these steps:

1. Add : config/database.yml to .gitignore file.
2. Rename database.yml to database.yml.sample
3. Check in the changes.
4. Now git will ignore the database.yml that you create in your project.

Keeping Security Credentials Out of Source Code Repository

Moonshine is supposed to keep the file in the shared folder and symlink it to the file under current project folder just by adding one line to the config/moonshine.yml

:shared_config
  - config/amazon_s3.yml

For some reason it created the symlink but it did not upload the file. I had to manually do it by :

cap shared_config:upload

on my laptop. On initial setup it actually worked for database.yml. I think it is because of cap deploy:setup command. Remember to add the config file to the .gitignore file so that it does not get checked into the repo.

Sunday, May 26, 2013

Consuming Webservices deployed on Google App Engine from Rails


Google App Engine is very attractive for exposing services that needs to be up and running 24x7 and scale automatically based on demand. Rails apps can consume RESTful services developed using Google Cloud Endpoints. Even though Google Cloud Endpoints is experimental,  platform developers will find very compelling. Any platform that can make a http request can consume the services.

1. Using OAuth 2.0 for Server to Server Applications
   
2. Google APIs Client Library for Ruby
Here is the github repo :  https://github.com/google/google-api-ruby-client

3. Code to Cloud in under 45 minutes

4. Slides from 18 to 34 from Pycon2013

5. Google Cloud End Points sample project
 
6. Python End Points

7. OReilly Webcast : Python for Google App Engine



The absolute uri: http://www.oracle.com/technetwork/java/javaee/jsp/index.html cannot be resolved in either web.xml or the jar files deployed with this application


To get the guestbook.jsp App Engine example working replace the tag library fn as follows:
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

Monday, May 20, 2013

Error: Cannot find module 'npmlog'


1. npm install -g yo grunt-cli bower gives the error:

Fix : sudo curl https://npmjs.org/install.sh | sh

How to upgrade Node.js


1. Check the version :  $node --version
   output will be like : n@0.9.3 /usr/lib/node_modules/n

2. To upgrade, run : $n 0.9.3
where, 0.9.3 is from the output of step 1.

Open a new terminal and type: $node --version
You should see the upgraded version.
   

Friday, May 17, 2013

SQLite3::BusyException: database is locked: ROLLBACK TO SAVEPOINT active_record_1

Caused SQLite3 to lock due to bug in a test. To fix:

1. ps -a | grep ruby
2. kill -s 9 12345

12345 is the process id that is the zombie rspec process.

Tuesday, May 14, 2013

WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0


Copied from https://github.com/sparklemotion/nokogiri/issues/742
Moved gem 'nokogiri' in the Gemfile to the top (just below gem 'rails') then:
brew uninstall libxml2
gem uninstall nokogiri
gem install nokogiri

Monday, May 13, 2013

AbstractController::ActionNotFound:


       Could not find devise mapping for path "/users/sign_in?user%5Bemail%5D=bparanj%40gmail.com&user%5Bpassword%5D=secret".
       This may happen for two reasons:
     
       1) You forgot to wrap your route inside the scope block. For example:
     
         devise_scope :user do
           get "/some/route" => "some_devise_controller"
         end
     
       2) You are testing a Devise controller bypassing the router.
          If so, you can explicitly tell Devise which mapping to use:
     
          @request.env["devise.mapping"] = Devise.mappings[:user]

Solution:


  before :each do
    request.env['devise.mapping'] = Devise.mappings[:user]
  end

Thursday, May 02, 2013

How to select the non highlighted button in the popup window on Mac OS

Go to Preferences -> Keyboard. At the bottom, turn on "All controls" under "Full Keyboard Access". Hit space to activate the secondary button.