Translate

January 8, 2024

 

Steps to migrate a MySQL database to PostgreSQL?

PostgreSQL vs. MySQL is an important decision when it comes to choosing an open-source relational database management system. Both PostgreSQL and MySQL are time-proven solutions

PostgreSQL is The world’s most advanced open source database, and MySql is popular for ease of development.

First thing WHY your project need to switch the database, consider below before you decide. 

Is current DB using any store procs, functions, triggers, TEMP tables TINYINT(1), Unsigned integer, HASH, KEY, scheduled events etc.

Once you decided to migrate existing MySql to PostgresQL then Export data from MySQL using tools like pgLoader or custom scripts. Modify the SQL dump to match the PostgreSQL syntax. You need to adjust data types, column lengths, and function, procedure calls to take advantage of pgSQL features. watch out for triggers / task scheduler etc.

Use the migration tool to transfer the data from the MySQL database to the PostgreSQL database.

Once data is migrated without any errors then you need to change your apps libraries , db connections, modify SQL queries in app code(Need to change syntax for some queries probably not all queries.)

DO Rigorous testing. Once you are confident then try adding and use advance feature of PostgreSQL LIKE FULL OUTER JOIN, Full-text search, CASCADE option to drop table’s dependent objects e.g., tables and views, Analytic functions, Data types array, hstore, and user-defined type, Boolean type, IP address data type, CHECK constraint, Partial indexes, Bitmap indexes etc.

DB optimization is endless process, you can add features step by step, Rigorous testing is essential for every step. 

IMPORTANT : USE BACKUP AND RECOVERY FEATURES FOR EVERY STEP YOU PERFORM SO THAT YOU CAN COME BACK TO STABLE STATE IF SOMETHING WENT WRONG.

November 19, 2015

Types of Caching in Rails

A few types of caching to know :
  • Page Caching: Save entire pages of an application without hitting the stack by returning cached pre-rendered pages. Good in applications without authentication and other highly dynamic aspects.
  • Fragment Caching: Allows fragments of view logic, for example partials or other bits of HTML that are independent from other parts, to be wrapped in a cache block and served out of the cache store when the next request comes in.
  • Action Caching: Works like Page Caching, except the incoming web request hits the Rails stack. This means that before filters (like authentication or other restrictions) can be run on it before the cache is served.
  • Rails.cache: All cached content except cached pages are stored in the Rails.cache.
  • HTTP Caching: HTTP caching occurs when the browser stores local copies of web resources for faster retrieval the next time the resource is required. It uses HTTP headers to determine if the browser can use a locally stored version of the response or if it needs to request a fresh copy from the server.

September 15, 2015

Uploading Multiple Images using CarrierWave

How to upload multiple image by selecting "ctrl + selction key" at same time.

CarrierWave
This gem provides a simple and extremely flexible way to upload files from Ruby applications.
This gem has convenient support for multiple file upload fields.

Following are the steps:
For Complete Source code click here

In Rails, add it to your Gemfile:


gem 'carrierwave'
 
bundle install
 
rails generate uploader photo

Create post scaffold

rails generate scaffold post title:string

Create post_attachment scaffold

post_attachment post_id:integer photo:string
 
rake db:migrate

In post.rb

class Post < ActiveRecord::Base
  has_many :post_attachments
  accepts_nested_attributes_for :post_attachments
end

In post_attachment.rb

class PostAttachment < ActiveRecord::Base
   mount_uploader :photo, PhotoUploader
   belongs_to :post
end

In post_controller.rb

def show
  @post_attachments = @post.post_attachments.all
end

 def new
   @post = Post.new
   @post_attachment = @post.post_attachments.build
 end
 
 def create
   @post = Post.new(post_params)
   respond_to do |format|
     if @post.save
       params[:post_attachments]['photo'].each do |a|
         @post_attachment = @post.post_attachments.create!(:photo => a)
       end
      format.html { redirect_to @post, notice: 'Post was successfully created.' }
     else
      format.html { render action: 'new' }
    end
   end 
 end
 
 private
  def post_params
    params.require(:post).permit(:title, post_attachments_attributes: [:id, :post_id, :photo])
  end

In views/posts/_form.html.haml

 = form_for(@post, :html => { :multipart => true }) do |f|
  .field
    = f.label :title
    = f.text_field :title
  = f.fields_for :post_attachments do |p|
    .field
      = p.label :photo
      = p.file_field :photo, :multiple => true, name: "post_attachments[photo][]"
  .actions
    = f.submit
 

In views/posts/show.html.haml

%p#notice= notice
%p
  %strong Title:
  = @post.title
- @post_attachments.each do |p|
  = image_tag p.photo_url
  = link_to "Edit Attachment", edit_post_attachment_path(p)
= link_to 'Edit', edit_post_path(@post)
|
\#{link_to 'Back', posts_path}
 
Update form to edit an attachment views/post_attachments/_form.html.haml

= image_tag @post_attachment.photo
= form_for(@post_attachment) do |f|
  .field
    = f.label :photo
    %br/
    = f.file_field :photo
  .actions
    = f.submit
 
 Now, update method in post_attachment_controller.rb

 def update
    respond_to do |format|
      if @post_attachment.update(post_attachment_params)
        format.html { redirect_to @post_attachment.post, notice: 'Post attachment was successfully updated.' }
      end
    end
  end


For Complete Source code click here

June 4, 2014

Apple launches new Swift programming language for MAC OS X and iOS

Apple developers now have a new tool in their toolbox.

Switft, a new programming language that can power all of its devices. Swift is the successor to Objective-C, the venerable language that Apple has used to build apps for the Mac and iOS. Swift includes full support for Cocoa and Cocoa Touch, so developers can build apps for the iPad and iPhone.

Swift uses the same LLVM compiler that Apple uses for Objective-C, so developers can run Swift, Objective-C,  and C code all in the same program, and brings a number of improvements.

Swift seems to get rid of Objective C's reliance on defined pointers; instead, the compiler infers the variable type, just as many scripting languages do. At the same time, it provides modern features similar to those found in C++ and Java, like well-defined namespaces, generics, and operator overloading. From the few fragments of code shown during the demo, Swift appears to rely heavily on the dot-notation that Apple introduced in an earlier iteration of Objective C.

Apple showed off a couple of cases where implementing the same algorithm in Swift provided a speedup of about 1.3X compared to the same code implemented in Objective C. It also showed off a Swift "playground," where code is compiled as it's typed and the output is displayed in a separate pane of the editing window. The goal here is to allow developers to test code fragments without having to recompile an entire complex project.

The Swift Programming Language, This book is available for download with iBooks on your Mac or iOS device, and with iTunes on your computer. Books can be read with iBooks on your Mac or iOS device. Download link

May 15, 2014

What happens when you run Rails migration?

Rails migration allows the creation of the table and provides the functionality that can be performed on a table with the following commands:

create_table(name, options)
drop_table(name)
rename_table(old_name, new_name)
add_column(table_name, column_name, type, options)
rename_column(table_name, column_name, new_column_name)
change_column(table_name, column_name, type, options)
remove_column(table_name, column_name)
add_index(table_name, column_name, index_type)
remove_index(table_name, column_name)


-Rails Migration also allows the use of pre-defined data type in the application as it supports all the data types. The data types consist of string, integer, float, etc.

-Rails Migration allows the users to use the valid column options like limit (:limit=> "50"), default (:default => "hello"), and null (:null => false implies NOT NULL)

February 5, 2014

What is the difference between Symbol and String in Ruby?

The symbol in Ruby on rails act the same way as the string but the difference is in their behaviors that are opposite to each other.

The difference remains in the object_id, memory and process time for both of them when used together at one time.

Strings are considered as mutable objects. Whereas, symbols, belongs to the category of immutable.

Strings objects are mutable so that it takes only the assignments to change the object information. Whereas, information of, immutable objects gets overwritten.

String objects are written like
irb(main):001:0> "string object apple".object_id #=>70278982314860
or
irb(main):002:0> "string object
apple".to_sym.object_id #=> 456148

Symbols are used to show the values for the actions like equality or non-equality to test the symbols faster then the string values.

January 14, 2014

Difference between Argument and Parameter in ruby on rails?

A parameter represents a value that the method expects you to pass when you call it.
An argument represents the value you pass to a method parameter when you call the method. The calling code supplies the arguments when it calls the method.

In simple words, parameters appear in method definitions; arguments appear in method calls.

For example, in below method, variables param1 and param2 are the parameters

def foo_method(param1, param2):
    .......
end

while calling the method, arg1 and arg2 are the arguments
 
foo_method(arg1, arg2)

January 9, 2014

What are filters? and how many types of filters are there in ruby?

Filters are methods that are run before, after or "around" a controller action.

Filters are inherited, so if you set a filter on ApplicationController, it will be run on every controller in your application.

Filter can take one of three forms: method reference (symbol), external class, or inline method (proc).

          after_filter
    append_after_filter
    append_around_filter
    append_before_filter
    around_filter
    before_filter
    filter_chain
    prepend_after_filter
    prepend_around_filter
    prepend_before_filter
    skip_after_filter
    skip_before_filter
    skip_filter

December 18, 2013

What is the difference between save and save! in Rails?

Save! performs all validations and callbacks. If any validation returns false, save! throws an error and cancels the save.

Save does not throw any error in the case above, but cancels the save. Also, the methods for validations can be bypassed.

October 16, 2013

What is the difference between delete and destroy in Rails?

The delete method essentially deletes a row (or an array of rows) from the database.
Destroy on the other hand allows for a few more options. First, it will check any callbacks such as before_delete, or any dependencies that we specify in our model. Next, it will keep the object that just got deleted in memory, this allows us to leave a message saying something like “ 'Object_name' has been deleted.” Lastly, and most importantly, it will also delete any child objects associated with that object!

September 24, 2013

Case equality operator === in ruby

To enable developers to write neat, compact code, Many classes take advantage of implementing their own versions of '==='. The '===’ operator is known as the case equality operator. The '===’ operator is used when testing cases in case statements.
def test_object number 
  case number
    when Fixnum
      case number 
        when 1  
          puts "It's One"
        when 2..10  
          puts "Between two and ten"
        else
          puts "-- #{number} -- is not between one and ten"
      end
    when String 
      puts "You passed a string"
    else "I have no idea what to do with -- #{number} --"
  end
end
for each 'when' statement the '===' operator is called on the when argument (1,2..10,String) and the case argument (number) is used for the comparison. For line 5 the comparison done shall be '1 === number'. For most classes ‘===’ is just an alias to ‘==’ however some classes redefine ‘===’ to allow for better functionality in case statements. In Ruby a Proc is a block of executable code, an anonymous function which can be passed around as if it were data. Like ‘===’, a Proc can map a number of arguments to either a true or false value.
is_weekday = lambda {|day_of_week, time| time.wday == day_of_week}.curry  
      
    sunday    = is_weekday[0]  
    monday    = is_weekday[1]  
    tuesday   = is_weekday[2]  
    wednesday = is_weekday[3]  
    thursday  = is_weekday[4]  
    friday    = is_weekday[5]  
    saturday  = is_weekday[6]  
      
    case Time.now  
    when sunday   
      puts "Day of rest"  
    when monday, tuesday, wednesday, thursday, friday  
      puts "Work"  
    when saturday  
      puts "Happy"  
    end  
Simple Factorial lambda function in Ruby
factorial = lambda do |n|
  n &lt;= 1 ? 1 : (n * factorial.call(n - 1))
end

factorial.call 3

July 24, 2013

SQL Injection in rails

How to avoid SQL Injection in rails

How to avoid SQL Injection in rails

SQL injection is a problem that every web developer needs to be aware of when accepting parameters that will during the life of the request be converted into SQL statements. Rails historically has done what it can to mitigate this risk for the developer by providing vehicles for sanitizing parameter inputs at the points when they are being converted for use inside of a SQL statement, however with Rails 3 there are numerous ways to execute a SQL statement against the database and some of these methods are safer than others.
Consider two cases where valid Rails code is vulnerable to SQL injection:

user inputed parameters

params[:query] = "'username'; DROP TABLE EMPLOYEE;"

CASE 1 - find_by_sql

User.find_by_sql("SELECT * FROM users WHERE (name = '#{params[:query]}'")

(Not Good)

generated SQL

SELECT users.* FROM users WHERE (email = 'user@example.com'); DROP TABLE EMPLOYEE; ')
(THIS STATEMENT WILL DROP TABLE EMPLOYEE)
The example above shows how find_by_sql can allow parameters submitted by a user to be directly entered into a SQL statement and how an attacker might use the vulnerability to wreak havoc. These types of find_by_sql statements used to be more commonly used in earlier versions of Rails (1.0 - 2.0) and it was through these statements that the Rails community realized that SQL injection was a problem that needed addressing. Here's another example prominent in the early Rails days:
User.find :first, :conditions => "(name = '#{params[:query]}')" ##(BAD BAD BAD) produces this SQL statement:

generated SQL

SELECT users.* FROM users WHERE (email = 'user@example.com'); DROP TABLE EMPLOYEE;')
(THIS STATEMENT WILL DROP TABLE EMPLOYEE)
The above example shows a common Rails idiom for performing an ActiveRecord query, as with the previous find_by_sql example the find query here is piping the param in directly and generating the exact same tainted SQL.
Fortunately, Rails core decided to make it easier to just do the right thing and provided ways to pass in parameters by using built-in filters that handle special SQL characters, which will escape ’ , " , NULL character and line breaks. Instead of passing in the parameter directly as a raw string, you can pass in an array to sanitize the tainted strings using the built-in filters:
User.find_by_sql(["SELECT * FROM users WHERE (name = ?)", params])
(GOOD)
User.find :first, :conditions => ["(name = '?')", params]
(GOOD)

generated SQL

SELECT * FROM users WHERE (name = 'user\'); DROP TABLE EMPLOYEE; ') (RETURNS NIL)
The distinction in the filtered SQL statement is the escaped single quote right after the t in Robert which prevents the name parameter from terminating and allowing the DROP TABLE EMPLOYEE from being executed since it remains a part of the string parameter. Additionally, Rails also included these built-in filters automatically when AR queries were called from find_by_something or a conditions hash:
User.find_by_name(params[:query])

(GOOD)

generated SQL

SELECT * FROM users WHERE users.name = 'username\'); DROP TABLE EMPLOYEE; ' (RETURNS NIL) User.find :first, :conditions => {:name => params}

(GOOD)

SELECT users.* FROM users WHERE users.name = 'username\'); DROP TABLE EMPLOYEE;' (RETURNS NIL)
Rails 3 introduced AREL, which is another way to perform ActiveRecord queries and with it came as well, another way to make the exact same SQL injection mistakes that are already listed above. However having gotten accustomed to looking for SQL injection vulnerabilities in the AR query formats above you might be lulled into thinking that the new and improved ActiveRecord query methods would just magically handle the tainted strings for you and you'd be dead wrong:
User.where("name = '#{params}'") (BAD) SELECT users.* FROM users WHERE (name = 'username'); DROP TABLE EMPLOYEE; ##') ##(THIS STATEMENT WILL DROP TABLE EMPLOYEE)
The nice thing is that the same fix can also be applied:
User.where(["name = ?", params]) SELECT users.* FROM users WHERE (name = ''username\'); DROP TABLE EMPLOYEE;
(RETURNS NIL)

July 9, 2013

Rails way web caching and caching

A web cache is a mechanism for the temporary storage (caching) of web documents, such as HTML pages and images, to reduce bandwidth usage, server load, and perceived lag. So that future requests for that data can be served faster.

Rails provides three types of caching techniques by default without the use of any third party plugins.
   
1) Page caching
2) Action caching
3) Fragment caching


1) Page Caching:

Page caching is a Rails mechanism which allows the request for a generated page to be fulfilled by the webserver (i.e. Apache or nginx), without ever having to go through the Rails stack at all. Obviously, this is super-fast. Unfortunately, it can't be applied to every situation (such as pages that need authentication) and since the webserver is literally just serving a file from the filesystem.
   
To enable page caching, you need to use the caches_page method.

class ProductsController < ActionController

  caches_page :index

  def index
    @products = Products.all
  end

  def create
    expire_page :action => :index
  end

end


By default, the page cache directory is set to Rails.public_path (which is usually set to the public folder) and this can be configured by changing the configuration setting config.action_controller.page_cache_directory.

In order to expire this page when a new product is added we could extend our example controller like above.


2) Action Caching:

One of the issues with Page Caching is that you cannot use it for pages that require to restrict access somehow(such as pages that need authentication). This is where Action Caching comes in. Action Caching works like Page Caching except for the fact that the incoming web request does go from the webserver to the Rails stack and Action Pack so that before filters can be run on it before the cache is served. This allows authentication and other restriction to be run while still serving the result of the output from a cached copy.
   
class ProductsController < ActionController

  before_filter :authenticate
  caches_action :index

  def index
    @products = Product.all
  end

  def create
    expire_action :action => :index
  end

end

You can also use :if (or :unless) to pass a Proc that specifies when the action should be cached. Also, you can use :layout => false to cache without layout so that dynamic information in the layout such as logged in user info or the number of items in the cart can be left uncached.

Action Caching and Page Caching runs in an after filter. Thus, invalid requests won't generate spurious cache entries as long as you halt them. Typically, a redirection in some before filter that checks request preconditions does the job.


3) Fragment Caching:

Sometimes you only want to cache a section of a page instead of the entire page. Fragment caching is the answer of this.
Fragment Caching allows a fragment of view logic to be wrapped in a cache block and served out of the cache store when the next request comes in.

As an example, if you wanted to show all the orders placed on your website in real time and didn't want to cache that part of the page, but did want to cache the part of the page which lists all products available, you could use this piece of code:
   

<% Order.find_recent.each do |o| %>
  <%= o.buyer.name %> bought <%= o.product.name %>
<% end %>

<% cache do %>
  All available products:
  <% Product.all.each do |p| %>
    <%= link_to p.name, product_url(p) %>
  <% end %>
<% end %>
   
The cache block in our example will bind to the action that called it and is written out to the same place as the Action Cache, which means that if you want to cache multiple fragments per action, you should provide an action_suffix to the cache call:
   
<% cache(:action => 'recent', :action_suffix => 'all_products') do %>
          All available products:

June 4, 2013

install_name_tool reporting malformed object in Mountain Lion

Problem:

Every-time I try to use install_name_tool on my machine it reports the following

install_name_tool: object: xxxxx.x.x.x.dylib malformed object (unknown load command 4) 


I observed that this error could be generated when building the binary.
Whenever I try to change something using install_name_tool. It produces the same result about malformed object (unknown load command 4)

Currently I have XCode Version 4.6.2 running on Mac OSX 10.8.3

I found the solution for this.

Solution:
After wasting lots of time trying different things finally I found that install_name_tool is not updated when XCode is updated. You need to install the Command Line Tool from XCode > Preferences.

install_name_tool on Mac OS X Mountain Lion.

This resolved the same error for me.

April 18, 2013

Install ssh on ubuntu

Install ssh with
sudo apt-get install ssh

Say yes to everything it asks you to install.
Note, you will now have an /etc/ssh/ directory under which you will find a ssh_config and sshd_config file you may have to uncomment a few lines in later.
You then want to run this command:
ssh-keygen -t rsa 

On safer side, it is a good idea to throw a pass phrase in there. For little security.  Make sure it is difficult to guess and NOT the same as your log in password.
Note, it should default to generating 2048 bit encryption which is always better than 1024. You will get a public and private file i.e.
id_rsa and id_rsa.pub
You put the id_rsa which is the private key, in the ~/.ssh directory. You put the public key one up on the server you are remotely connecting too. You can cut and paste it in usually. Make sure you do not introduce any unwanted white space in it. DO NOT put the private key one up on the server you are connecting too.

Troubleshooting:
You may need to restart the service/deamon with
sudo service ssh restart 

This would be necessary if you changed anything in one of the config files. Make sure your permissions are right on the ~./.ssh directory and the files in there.
drwx------ # for .ssh directory
-rw------- # id_rsa for the private key 


Now type from your Ubuntu prompt:
ssh username@yourhost.com

April 15, 2013

Pymongo - TypeError: index 'password' cannot be applied to Cursor instances

In the 10Gen course I am taking of Mongo-db, we are using python to access mongo via pymongo.

I received this "TypeError : index … cannot be applied to Cursor instances" error while attempting to do the following:

user = self.users.find({'_id' : username})
...
salt = user['password'].split(',')[1]



where the "self" variable gave a connection to the mongo db, "users" was a collection on that db, and "username" was a string variable passed into a function containing this code. Initially I didn’t realize that the find() method will always return a full cursor rather than a single document, even if the where clause specifies the primary key field, _id. I’m currently working with iplbeats right now, which when retrieving a "cursor" (users) will always return a single "document" (sObect) if the primary key is supplied in the where clause.

The solution was clear: replace the find() method with the find_one() method to return a document rather than a cursor.

 

April 9, 2013

How to avoid SQL Injection in Rails

SQL injection is any situation in which a user can manipulate a database query in an unintended manner. Consequences of SQL injection vulnerabilities range from data leaks, to authentication bypass, to root access on a database server.

Most Rails applications interact with a database through ActiveRecord, the default and convenient Object Relational Mapping (ORM) layer which comes with Rails. Generally, use of ORMs is safer. ORM can provide abstraction and safety and allow developers to avoid manually building SQL queries. ORM can incorporate best practices and prevent loosely handling of user input.

sqlquery = "SELECT * FROM users WHERE name = '#{name}' AND password = '#{password'} LIMIT 1"
results = DB.execute(sqlquery)

Safer, simpler code like
User.where(:name => name, :password => :password).first

Rails framework will protect them as long as they avoid the "obviously dangerous" methods, like find_by_sql.
ActiveRecord does provide parametrization of queries or some methods. But for some methods it does not provide parametrization of sql queries, these methods are not intended to be used with user input.
Here is an example of using exists?
User.exists? params[:user_id]
However, there is no guarantee params[:user_id] is a string.
Hacker could send a request with ?user_id[]=some_hack_string, which Rails will turn into an array ['some_hack_string']. Now the argument is an array, the first element of which is not escaped.

To avoid this problem, we need to convert the user input to the expected type:
User.exists? :id => params[:user_id]
OR
User.exists? params[:user_id].to_i
This should be the approach for all uses of user input.

April 2, 2013

How to Install PostgreSQL on a Mac

This is a quick guide for installing PostgreSQL (Postgres) on a Mac with Homebrew. If you are planing to use Postgres in your Ruby on Rails App, this tutorial will get you up and running in no time.
I am assuming that you have Homebrew, Ruby on Rails, Xcode, git, rvm etc installed in your mac.

Step 1: Update Homebrew
Before you install anything with Homebrew, you should always make sure it's up to date and that it's healthy by executing following command
brew update
brew doctor

Step 2: Install Postgres

brew install postgresql

When you install Postgres, you will see a bunch of output in your Terminal. There are few instructions like, creating first database, migrating existing database, start/stop PostgreSQL etc. Keep this instructions aside for future reference if you want.

Step 3: Create/Upgrade a database
If this is fresh installation of Postgres with Homebrew, you’ll need to create a database with:

initdb /usr/local/var/postgres -E utf8

I copied this from Terminal output.

Step 4: Create a user
If you want a new user for your new rails app, you can create new user by using createuser command. This will ask few questions.

createuser username 

Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n

Step 5: Create a database for new user
Create the two databases you will need, development and test. With option -O we can specify the owner of the database.
createdb -Ousername -Eutf8 newapp_development
createdb -Ousername -Eutf8 newapp_test

Done.....
To Verify the installation and database users we can use shell similar to MySQL
psql -U username newapp_development

You will get following prompt

newapp_development=>

Type "help" for help.

April 1, 2013

How to turn off ri and rdoc installation

Most often we never refer to ri and rdoc for all the gems installed on our system.
Sometimes duplicate ri and rdoc are installed on our system when we use ruby version manager (rvm). These documentation takes up few MB of your harddisk. Even space is not a BIG issue.
These ri and rdoc took considerable time while installation. We can increase gem installation time 8x by turning off the ri and rdoc installation.
Turn off ri and rdoc installation. Sure, you can do this on the command-line, like so:

sudo gem install haml --no-ri --no-rdoc

If, like me and most developers, you would rather read the documentation online and have your gems install quickly, then you can disable the documentation generation by creating a file called ".gemrc" in your user's home directory

Better, though, is to set this up as the default in your ~/.gemrc file.

---
:verbose: true
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com/
:update_sources: true
:backtrace: false
:bulk_threshold: 1000
:benchmark: false
gem: --no-ri --no-rdoc

March 18, 2013

Run RhoMobile Apps With XCode Version 4.6.1

I started building Rhodes application on my mac book pro. I had followed every step for building the mobile application using Rhodes. I did configured the Rhodes using rhodes-setup command. On my machine I didn't installed android and blackberry sdk so I skipped those settings.
When I run my application by using following command:

rake run:iphone

I am getting following error;

xcodebuild: error: SDK "iphonesimulator5.0" cannot be located. 

I simply solved this issue by changing the configuration settings of Rhodes.
I found that the invalid SDK is pointed in BUILD.YML

I changed iphone simulator sdk in iphone section in build.yml like this

sdk: iphonesimulator6.1

After this my application could run on the iPhone simulator!