Anil Punjabi's Blog

The Go-to-market strategy checklist

So you’ve got a cool new product and you just want people to find out about it. 

Perfect !!!

image

In this post we will explore what every modern go-to-market strategy should include.

If you are reading this post you are likely not an IBM or Oracle employee with deep pockets dedicated for market strategy. Perhaps you are the lone co-founder at a tech company who doesn’t have the budget to hire a dedicated marketing guru. Fear not. You’ve arrived at the right destination.

Few key points to keep in mind.

a) Start small.

b) Keep moving forward everyday.

c) Traction is everything.

If you are developing a product where your target audience can be any business or consumer then you are at the right place. Your goal should be to get your first few customers. To do this you have to understand their buying behavior. 

  1. Understand the buying process: Identify the decision makers, approvers, recommenders, influencers and disruptors.
  2. Understand the business issues for decision makers and develop a value proposition that resonates with them. 
  3. Establish a differentiated position from substitutes and alternatives.
  4. Identify partners for creating awareness, interest, consideration, purchases, implementations and supporting customers.

Somehow get them to agree to meet you where you can present all this information. Lock them down as a client even if you have to pay them to be your customer. 

Your go-to-market strategy should be aligned with your internal product management process as well.  

  1. Prepare a product roadmap and be ready to present it to potential customers.
  2. Deliver on key milestones and keep your potential clients updated on your progress.

 

Assuming you have overcome the hump of signing your first few key clients, you should start thinking about scaling your marketing team. These techniques will help.

  1. Document the distribution strategy and corresponding sales process.
  2. Create an integrated demand creation plan to create qualified opportunity.
  3. Invest in a sales pipeline management software, like SalesForce.
  4. Develop a comprehensive and methodical demand management plan to follow-up on qualified opportunities.
  5. Prepare an implementation plan to ensure the offering is set-up to perform properly.

 

A marketing team is only as good as the support team. So invest a little time in your support efforts.

  1. Train the support organization to handle implementation and end user inquiries.
  2. Encourage your IT team to spend time on improving site performance.

 

Have a solid social media presence.

  1. At a bare minimum have a presence on the following social media networks(Pinterest, Facebook, Twitter, Google+)
  2. Develop key metrics for each platform and improve them over time. 

Key points to keep in mind when developing your social media plan.

  • Your social media listeners are like your employees (with no pay).
  • You should feed them fresh content as often as possible.
  • You should reward them for their support.
Creating sample data using Fixtures in Ruby on Rails

Fixtures allow you to populate your testing database with predefined data before your tests run. Fixtures are database independent and assume a single format: YAML.

You’ll find fixtures under your test/fixtures directory. When you run rails generate model to create a new model, fixture stubs will be automatically created and placed in this directory.

YAML

YAML-formatted fixtures are a very human-friendly way to describe your sample data. These types of fixtures have the .yml file extension (as in users.yml).

Here’s a sample YAML fixture file:

# lo & behold!  I am a YAML comment!

david:

 name: David Heinemeier Hansson

 birthday: 1979-10-15

 profession: Systems development

steve:

 name: Steve Ross Kellock

 birthday: 1974-09-27

 profession: guy with keyboard

Each fixture is given a name followed by an indented list of colon-separated key/value pairs. Records are separated by a blank space. You can place comments in a fixture file by using the # character in the first column.

ERB in YAML Fixtures

ERB allows you to embed ruby code within templates. YAML fixture format is pre-processed with ERB when you load fixtures. This allows you to use Ruby to help you generate some sample data.

<% earth_size = 20 %>

mercury:

  size: <%= earth_size / 50 %>

  brightest_on: <%= 113.days.ago.to_s(:db) %>

venus:

  size: <%= earth_size / 2 %>

  brightest_on: <%= 67.days.ago.to_s(:db) %>

mars:

  size: <%= earth_size - 69 %>

  brightest_on: <%= 13.days.from_now.to_s(:db) %>

Anything encased within the

<% %>

tag is considered Ruby code. When this fixture is loaded, the size attribute of the three records will be set to 20/50, 20/2, and 20-69 respectively. The brightest_on attribute will also be evaluated and formatted by Rails to be compatible with the database.

When do fixtures load up

Rails by default automatically loads all fixtures from the test/fixtures folder for your unit and functional test. Loading involves three steps:

Remove any existing data from the table corresponding to the fixture

Load the fixture data into the table

Dump the fixture data into a variable in case you want to access it directly

Testing techniques in Ruby on Rails

There are three main ways to test your app using Ruby On Rails. It is true for any web application in any language as well but Rails makes it even easier to complete these tests.


Unit Tests (for your models): 

When you use rails to generate scaffold for a resource among other things it creates a test stub in the test/unit folder:

$ rails generate scaffold post title:string body:text

create  app/models/post.rb

create  test/unit/post_test.rb

create  test/fixtures/posts.yml

The default test stub in test/unit/post_test.rb looks like this:

require ‘test_helper’

class PostTest < ActiveSupport::TestCase

  # Replace this with your real tests.

  test “the truth” do

    assert true

  end

end


Functional Tests (for your controller):

In Rails, testing the various actions of a single controller is called writing functional tests for that controller. Controllers handle the incoming web requests to your application and eventually respond with a rendered view.

You should test for things such as:

was the web request successful?

was the user redirected to the right page?

was the user successfully authenticated?

was the correct object stored in the response template?

was the appropriate message displayed to the user in the view?

Now that we have used Rails scaffold generator for our Post resource, it has already created the controller code and functional tests. You can take look at the file posts_controller_test.rb in the test/functional directory.

Let me take you through one such test, test_should_get_index from the file posts_controller_test.rb.

test “should get index” do

  get :index

  assert_response :success

  assert_not_nil assigns(:posts)

end

In the test_should_get_index test, Rails simulates a request on the action called index, making sure the request was successful and also ensuring that it assigns a valid posts instance variable.

The get method kicks off the web request and populates the results into the response. It accepts 4 arguments:

The action of the controller you are requesting. This can be in the form of a string or a symbol.

An optional hash of request parameters to pass into the action (eg. query string parameters or post variables).

An optional hash of session variables to pass along with the request.

An optional hash of flash values.

Example: Calling the :show action, passing an id of 12 as the params and setting a user_id of 5 in the session:

get(:show, {‘id’ => “12”}, {‘user_id’ => 5})

Another example: Calling the :view action, passing an id of 12 as the params, this time with no session, but with a flash message.

get(:view, {‘id’ => ‘12’}, nil, {‘message’ => ‘booya!’})

If you try running test_should_create_post test from posts_controller_test.rb it will fail on account of the newly added model level validation and rightly so.

Let us modify test_should_create_post test in posts_controller_test.rb so that all our test pass:

test “should create post” do

  assert_difference(‘Post.count’) do

    post :create, :post => { :title => ‘Some title’}

  end

  assert_redirected_to post_path(assigns(:post))

end

Now you can try running all the tests and they should pass.

Integration Tests:

In Rails, testing the various actions of a single controller is called writing functional tests for that controller. Controllers handle the incoming web requests to your application and eventually respond with a rendered view.

Integration tests are used to test the interaction among any number of controllers. They are generally used to test important work flows within your application.

Unlike Unit and Functional tests, integration tests have to be explicitly created under the ‘test/integration’ folder within your application. Rails provides a generator to create an integration test skeleton for you.

$ rails generate integration_test user_flows

      exists  test/integration/

      create  test/integration/user_flows_test.rb

Here’s what a freshly-generated integration test looks like:

require ‘test_helper’

class UserFlowsTest < ActionDispatch::IntegrationTest

  fixtures :all

  # Replace this with your real tests.

  test “the truth” do

    assert true

  end

end

Integration tests inherit from ActionDispatch::IntegrationTest. This makes available some additional helpers to use in your integration tests. Also you need to explicitly include the fixtures to be made available to the test.


Agile vs Waterfall — Good & Bad

Having worked in both Agile and Waterfall environment it is easy to say that Agile is the better way to manage the release cycles. 

At least in principle, everybody agrees that Agile should be better. 

Not for every project though. Let’s consider a few cases. 

Let’s dig in with the core definitions first. 

Waterfall


Waterfall method of product development is simply a sequential process wherein a large project is broken down into multiple development phases. 

Each phase is then scoped out with a lot of detail documentation and a project plan is outlined that acts as a working plan on when we will get through the phases.

Here are some typical phases:

It sounds like a lot of work upfront.
And it really is !!!
While you are writing documentation you might find out that the company is not going to build the next phase because the customer is not interested to pay for it. 
Waterfall does not insist on any time limit for any of those phases so projects might go on for as long as 2 years at times. This happened a lot during my early days of my development work at Siemens & other places.
Some 10 years ago, Waterfall was the (new) best way for product development. Iterative product development was considered only for the crazies (and some intellectual startups).

Agile

Somewhere in the mid 2010’s the crazy intellectual startups started gaining momentum, market share & and shared their success stories with the Agile methodologies for product development. Agile was the new kid on the block.
Since then Agile has been the new mantra for quick iterative execution style. At it’s core it is still the same key principle of dividing the project implementation into multiple phases. However, these phases are crammed down to complete in two to three weeks. 
The key difference between a Waterfall and Agile method are:

Agile
Emphasizes short iterative development (sprint) cycles to deliver a usable, working version of the application being developed.


Waterfall
Emphasizes detailed specifications and does not specify any release or development (sprint) timeline.  
This one key difference between the two methodologies has the biggest on the final product that is delivered. Agile products are often applauded for their near perfect match with their customer’s need. 



Special Cases


Few years ago I was involved in a migration project that had a hard deadline. This project would migrate users from the old platform to the new platform.

The Engineering team followed the Agile method of product development.

However the Product management team prepared detailed documentation similar to something you might find in a Waterfall artifact stack. 

A project like this is unique and demands a blend of the two approaches primarily because a lightweight Agile PRD would not be sufficient. 

So much good stuff, so what’s bad about Agile?

There must be something.

And, yes there is :)

Everybody knows that engineers love to build products and they are very passionate about their products. The best way to make an engineer unhappy is to have them work on one project for 3 weeks, then pull them out to work on something else, and so on. 

The beauty of Agile development is that new projects can get prioritized higher than the ones that the engineers are currently working on and new projects can be plugged in at the end of the 3-4 weeks Sprint cycle. 

Now imagine changing priorities every 3-4 weeks for a development team. Sure it is still Agile. However, now you are really exploiting Agile. One thing to keep in mind with Agile is that Agile is still Waterfall broken down in small manageable chunks. It is not meant to be used as a tool to change priorities every 3-4 weeks. 

The best way to drive Agile at your company is to first plan long-term.  Keep stakeholders involved and engaged every step of the way and follow these guidelines:

  1. Build a rough roadmap (12 months if possible)
  2. Work closely with your Sales, Product, Marketing & Engineering team to solidify a  roadmap for the next quarter
  3. Evangelize these two roadmaps with the rest of the company
  4. Start writing user stories & work towards developing detailed use cases
  5. Build UX & UI docs
  6. Get estimates on various user stories from your developers
  7. Develop a product backlog and put the estimates with the product backlog
  8. Start Sprint Planning Process
  9. Run Sprint Cycles

Use common sense above all else and if things fall apart, change the process to fill in the gaps. Iterate :)

UX vs UI

Some people use the words UX and UI interchangeably as if they are one and the same. Let’s find out how different they are and why people seem confused by it. 

UI(User Interface) is easy to explain: It is simply what the users will see. 

Say you are designing a login page for your iPad app. Your UI designer would create a nice photoshop visual like this:

Or for an iPhone app they might design something like this:

(Good) Designers have a pretty good sense of the color scheme and do an excellent job of matching the right colors with the rest of the app (or site). 

You might think that this is sufficient information to hand over to a developer so that they can start coding. You would be soooo wrong !!!

Those visuals do a good job of highlighting how the page looks like but they really leave the door open to a lot of interpretation.

Let’s look at UX (User Experience)

A good UX deliverable often includes a set of documents such as:

  • Site flows and navigation maps (sitemaps)
  • Wireframes
  • And a lot of useful notes next to the wireframes. 
  • UI Designs (YES YES YES - UI designs are actually a part of the UX deliverables)

You might choose to develop the wireframes and focus purely on the UI design. If you do so, don’t forget to include the notes on the right. 

Let’s look at another wireframe example.

Let’s zoom in on the contents on the left side:

Notice that the notes talk about the overall workflow on the page. It highlights the items that are grayed out, how the filters work, how the dialog box opens up. 

Page flow diagrams are also very important to describe a UX properly. Here’s an example:

To summarize:

UX design is a very important deliverable from a Product Management point of view.

UX designs includes several artifacts including:

  • UI Designs
  • Page Navigation Map
  • WireFrames + Useful notes that talk about the small little use cases

Now User Stories, Storyboards, Scenario Diagrams, Style Guides, Use Cases and Powerpoint Presentations are also sometimes considered to be part of the overall UX deliverable. 

Sure. 

Anything can be considered UX.

Anything that helps in defining the user workflow and experience can be considered UX. Go crazy with it !!!

User Stories vs Use Cases

Product Managers and engineers often describe a user story and a use case as one and the same. They are not. 

Agile development process has made user stories a very popular tool for planning, estimation & execution. However, they serve poorly when it comes to actually building a feature. That’s when use cases come into play. 

Let’s dive in. 

User Story: A user story is something you write on a small yellow post-it note so that you can post it on your Agile planning board. It is usually a single sentence describing the problem. Something like:

As a user I want to login in by entering username & password and checkout cart items.

In the Agile planning process the developers would also write the Priority and estimates on this story card. 

At the back of the card you would define the acceptance criteria for this story. 

Acceptance Criteria

  1. A user cannot view the checkout cart unless they are authenticated.
  2. A user is given the option to reset their password in case they forgot their password.
  3. A user can browse the rest of the site without being authenticated.

Look familiar?

User Stories Board

It is just enough to explain the problem.

Somewhat enough to get estimates from the engineer.

Barely enough to start development.

There are some teams out there that develop code purely based on user stories. If you are one of those teams, Good luck to you !!!

Use Cases: A use case goes a lot deeper than the one liner user story. The same user story that we covered earlier takes the form as shown below:

Name: UC-8-User login

Summary

A user logs in using their username and password.Rationale

Users need to authenticate themselves before they can purchase an item. A user login page would ensure that they pass the security test before they can place an order. 

They should however still be able to access the unsecured(public) content without having to login.

Users

Only users that want to access their private contentPreconditionsA user clicks on a link that is only accessible for authenticated users.

Basic Course of Events

  1. The user arrive at the home page.
  2. The user adds an item to cart.
  3. The user clicks on the checkout cart button.
  4. The user is presented with the login and password fields.
  5. User enters the login and password fields and can now continue the cart checkout process.

Alternative Paths

Alt Path #1

  1. In Step 5, the user might choose to click on the “Forgot Password” link and choose to follow that process. 
  2. In this case the user would be asked to enter their email address. 
  3. The user would then receive a link with instructions on how to reset the password.

Alt Path #2 

  1. Other exception cases….like over 5 incorrect password attempts should lock account, invalid email message, etc.

Postconditions

User logs in and is able to view the cart checkout screen. 


Ruby and Ruby on Rails Interview Questions and Answers

Here’s a rather detailed list of Ruby on Rails questions and answers. Hope you find them useful.

What are ruby gems?

This is a very open ended question and you might be better of to start with the basics first:

- A gem is nothing more than a piece of ruby code packaged as a library so that it can be imported and used by others in their programs.

- A Ruby gem is therefore simply a library that is written in the ruby programming language. 

- You can add that you often look for ruby gems on rubygems.org. If you have downloaded any recent gems it might be a good idea to mention those. Some of the popular Ruby gems that your interviewer will likely be faimilar with are:

> rails

> activerecord

> rake

> activeadmin

- Finally Rubygems is the name of the project that wrote the “gem” ruby library. [You need not mention this during the interview]

What is the difference between a Symbol and String?

Symbols and string are used interchangeably by various developers and their usage within gems can be confusing at times. You can think of Symbols as faster & immutable strings.

Once a string is used up it is marked for cleaning by the garbage collector but it is not cleaned up immediately and it cannot be reused.

Symbols live for the duration of the session. You might say that this leads to increased memory usage however by keeping the symbol alive a bit longer it can be reused again. 

Here’s a terminal irb session that will provide more insight. 

puts :"I am a symbol".object_id
457908

puts :"I am a symbol".object_id
457908

puts :"I am a symbol".object_id
457908

puts "I am a string".object_id
70343000106700

puts "I am a string".object_id
70343000094220

Notice that the object_id stays the same when symbols are created. This happens because the ruby interpreter uses the same heap memory location each time. The symbol was never completely released.

However, in the case of strings the memory is marked for cleanup each time and a new memory is allocated. 

Another big difference is that strings can be modified. They are mutable.

So, this would work:

puts "I am a string" << " for you"
I am a string for you

However, symbols are immutable. 

So, this would throw an error:

puts :"I am a symbol" << :" for you"
NoMethodError: undefined method `<<' for :"I am a symbol":Symbol

from (irb):16
from /Users/anilo/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
1.9.3p0 :017 > puts :"I am a symbol" << " for you"
NoMethodError: undefined method `<<' for :"I am a symbol":Symbol

What is the purpose of yield?

The interpreter essentially invokes a separate piece of code and places it in the location. You might say it is similar to a method calling another method. Let’s understand a little bit of background about where yield might be useful first. 

The Rails framework encourages you to write code that is DRY (Don’t Repeat Yourself).

Developers often write common code in a central file and then they write the custom code in the specific files. Let’s say you are building a web application and you want all pages to have a common header, a common footer, the same “Welcome user-name!” message.

You can put all this common code in your application.html.erb file.

<html> .... common page title
.. standard header... 
<body> 
..common page title,
 <%= yield %>
..footer code can go here... </body> 
</html>

The rest of the custom code can go in your specific file. Say the page you are creating is the list of articles. Then in your implementation file you would just write the code for pulling in the articles and the final page displayed to the user would be your custom code which will be placed instead of the <%= yield %> code in the application.html.erb file.

What are class variables? How do you define them?

Class variables are created using the @@ prefix to denote the variable as class level. 

It works just like any other variable, however in the case of inheritance it works more like a static variable that is accessed across all variable instances.

Another example can be found here:

class DemoClass 
 @@my_var = nil
  def initialize
    @@my_var = "hello world"
  end
  def my_var
    puts @@my_var
  end
end
class Demo2Class < DemoClass
  def initialize
    @@my_var = "goodbye world"
  end
end
demo1 = DemoClass.new
demo1.my_var
demo2 = Demo2Class.new
demo2.my_var
demo1.my_var
The output would be as shown below:
hello world
goodbye world
goodbye world

This may appear strange at first, but really all it shows is that the variable my_var is shared across both object instances.


How do you define instance variables?

Instance variables are defined using single @ symbol.

@foo = "Hello"

Within a class they can be declared as below:

class Animal
 attr_accessor :name, :age
end

Next you can query an object instance to find which instance variables it has.

anim = Animal.new
anim.instance_variables 
=> [ ]
anim.name="John"
anim.age = 3
 => [:@age, :@name] 

In the above case we did not put the @ symbol before the instance variables but it is implied. 

How do you define global variables?

Global variables are defined using single $ symbol.

$foo = 5

It can be declared anywhere and used anywhere. 

Generally you shouldn’t declare too many global variables but sometimes it makes sense to do so. One nice feature of a global variable is that it can be used to trigger a procedure if it’s value changes.

trace_var :$foo, proc{puts "$foo is now #{$foo}"}

This set the tracking and the procedure is called whenever the value of $foo changes.

$foo=7
$foo is now 7
 => 7 

Does Ruby support constructors? How are they declared?

Constructors are supported in Ruby. They are declared as the method initialize, shown below. The initialize method gets called automatically when Album.new is called.

class Album
  def initialize(name, artist, duration)
    @name     = name
    @artist   = artist
    @duration = duration
  end
end

How can you dynamically define a method body?

An instance method can be defined dynamically with

Module#define_method(name, body),

where name is the method’s name given as a Symbol, and body is its body given as a Proc, Method, UnboundMethod, or block literal. This allows methods to be defined at runtime, in contrast to def which requires the method name and body to appear literally in the source code.

class Conjure
  def self.conjure(name, lamb)
    define_method(name, lamb)
  end
end

# Define a new instance method with a lambda as its body

Conjure.conjure(:glark, ->{ (3..5).to_a * 2 })
Conjure.new.glark #=> [3, 4, 5, 3, 4, 5]  

Module#define_method is a private method so must be called from within the class the method is being defined on. Alternatively, it can be invoked inside class_eval like so:

Array.class_eval do
  define_method(:second, ->{ self.[](1) })
end
[3, 4, 5].second #=> 4

Kernel#define_singleton_method is called with the same arguments as Module#define_method to define a singleton method on the receiver.

File.define_singleton_method(:match) do |file, pattern|
  File.read(file).match(pattern)
end
File.match('/etc/passwd',/root/) #=> #<MatchData "root">

What is a Range?

Range is a great way to declare continuous variables. You should use it to declare arrays and other types of collections. 

range1 = (1..4).to_a
 => [1, 2, 3, 4] 
puts range1
1
2
3
4

You can also create strings in this format and it fills in the interim values automatically.

range2 = ('bar'..'bat').to_a
puts range2
bar
bas
bat
Since the end result of using range is an array you can also iterate over it just like any other array.
range2.each do |str|
   puts "In Loop #{str}"
end

This produces the result as shown below:

In Loop bar
In Loop bas
In Loop bat

How can you implement method overloading?

This one’s a tricky question. If you have a background in Java then you must know that method overloading is simply multiple methods with same name but different signatures/parameters.

In the case of Ruby method overloading is not supported. 

However, it does support the overall goal of passing variable number of parameters to the same method. You would implement it like this:

class MyClass  
  def initialize(*args)  
    if args.size < 2  || args.size > 3  
      puts 'This method takes either 2 or 3 arguments'  
    else  
      if args.size == 2  
        puts 'Found two arguments'  
      else  
        puts 'Found three arguments'  
      end  
    end  
  end  
end  

The output can be seen here:

MyClass.new([10, 23], 4, 10)  
Found three arguments
MyClass.new([10, 23], [14, 13]) 
Found two arguments

SO: You can get the same effect as method overloading but you just have to manage the number of variables inside your method itself.

What is the difference between ‘&&’, ‘and’ and ‘&’ operators?

The ‘&&’ and ‘and’ are both logical and statements. They ‘&&’ operator has higher precedence though. Here’s an example of illustrate this in more detail:

foo = 3
bar = nil
a = foo and bar
# => nil
a
# => 3
a = foo && bar
# => nil
a
# => nil
Notice how the statement ‘a = foo and bar’ actually behaves like ‘(a = foo) and bar’

How can you create setter and getter methods in Ruby?

The setter and getter methods can be created manually by the developer or it can be auto-generated by Ruby using the attr_accessor method specifier.

class Animal
   attr_accessor :name, :age
end
anim = Animal.new
 => #<Animal:0x007f8ea20841d8> 
anim.age = 3
 => 3 
anim.name = "Steve"
 => "Steve" 
puts anim.name, anim.age
Steve
3

Of course you can achieve the same result by implementing all the setter and getter methods like this as well:

class Animal
  def name # this is the getter method
    @name
  end
  def name=(name)  # this is the setter method
    @name = name
  end
#...same for age...
end


What is the convention for using ‘!’ at the end of a method name?

The ! indicates that the method is about to change the object itself.

Here’s an example:

foo = "A TEST STRING"  # a string called foo

foo.downcase!     # modifies foo permanently
a test string

puts foo          # prints modified foo
a test string

Similarly if you did not want the object to be changed you could have something simple like:

foo2 = "A 2nd Test String"  # a string called foo 

foo2.downcase     # modifies foo temporarily
a 2nd test string 

puts foo2 nbsp;    # prints original foo 
A 2nd Test String

What is a module?

A module is like a class. Except that it can’t be instantiated or subclassed.

In OOP paradigm you would store methods & variables that represent variables in a single class. Say you want to create an Employee representation then the employee’s name, age, salary, etc. would all go inside a Employee class, in a file called Employee.rb

Any methods that act on those variables would also go inside that class.

You can achieve the same effect by putting all the variables and methods inside a Employee module:

module Employee
  ..variables.
  ...methods
end

The main difference between the class & module is that a module cannot be instantiated or subclassed.

Module are better suited for library type classes such as Math library, etc. 

Does Ruby support multiple inheritance?

Ruby does not support multiple inheritance.

How can you achieve the same effect as multiple inheritance using Ruby? What is mixin?

Ruby offers a very neat alternative concept called mixin. Modules can be imported inside other class using mixin. They are then mixed-in with the class in which they are imported.

Here’s an example:

module Debug
  def whoAmI?
    "I am #{self.to_s}"
  end
end

class Photo
 include Debug
end

ph = Photo.new

"I am : #<Photo:0x007f8ea218b270>"

As you can see above the class Debug and it’s method “whoamI?” were mixed-in (added) with the class Photo.

That’s why you can now create an instance of the Photo class and call the whoAmI? method.

ph.whoAmI?
 => "I am : #<Phonograph:0x007f8ea218b270>" 

How will you implement a singleton pattern?

Singleton means single instance. 

So, the goal of a singleton pattern is to write a class definition but only allow the creation of the single instance of that object. 

This can be achieved nicely with the singleton gem as shown below:

require 'singleton'
 class Logger
  include Singleton
  def initialize
    @log = File.open("logfile.txt", "a")
  end
  def log(msg)
    @log.puts(msg)
  end
end

Adding the singleton as a mixin to the 

Logger.instance.log('This is just a test message')

The code above will create a single instance of Logger and simply put the message in the logger file.

Singleton patterns are mostly used for DB instance, Logger instance, etc. —- cases where there should be ONE and only ONE instance of the object that is used. 

Sometimes you might like to actually hold on to the logger object and use it everywhere you can do so by the following command:

logObj = Logger.instance

Notice you cannot use the Logger.new to create an object instance because this is a singleton object and therefore calling ‘new’ would fail.

How will you implement an observer pattern?

Let’s review first what an observer pattern is all about.  

The observer pattern (sometimes known as publish/subscribe) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems.

You might have used them in other programming languages as listener objects. You use them whenever a button is clicked on the screen and a method gets called automatically. 

As in the case of the singleton pattern, the observer pattern is also implemented by mixing in a module. 

In the Ruby implementation, the notifying class mixes in the Observable module, which provides the methods for managing the associated observer objects.

And, the observers must implement the update method to receive notifications.

Here’s an example. Say you want to send an SMS alert to users if a company stock drops then you can do something like this:

require "observer" 
require "observer" 
  class Ticker # Periodically fetch a stock price 
    include Observable 
 	attr_accessor :price 
    def initialize symbol, price 
      @symbol = symbol 
  	@price = price 
	end
    
	def run 
      lastPrice = nil 
      loop do 
        @price = @price+Random.rand(11) 
        print "Current price: #{price}\n" 
        if @price != lastPrice 
          changed                 # notify observers 
          lastPrice = @price 
           notify_observers(Time.now, @price) 
         end
       end 
    end 
  end
 
  class Warner
     def initialize ticker  
     ticker.add_observer(self)   # all warners are observers     
  end   
end 
  
class SMSAlert < Warner     
   def update time, price       # callback for observer         
      print "--- #{time.to_s}: SMS Alert for price: #{price}\n"     
   end   
end  

class EmailAlert < Warner     
   def update time, price       # callback for observer         
      print "+++ #{time.to_s}: Email Alert Price changed to #{price}\n"    
   end
 end

Now let’s initialize the classes and run them:

ticker = Ticker.new("MSFT", 307) 
SMSAlert.new(ticker) 
EmailAlert.new(ticker)
 ticker.run 
 Current price: 312 
 --- 2012-02-22 01:26:04 -0800: SMS Alert for price: 312 
 +++ 2012-02-22 01:26:04 -0800: Email Alert Price changed to 312 
 Current price: 321 
 --- 2012-02-22 01:26:04 -0800: SMS Alert for price: 321 
 +++ 2012-02-22 01:26:04 -0800: Email Alert Price changed to 321 
 Current price: 323 
 --- 2012-02-22 01:26:04 -0800: SMS Alert for price: 323 
 +++ 2012-02-22 01:26:04 -0800: Email Alert Price changed to 323
 Current price: 329 
 --- 2012-02-22 01:26:04 -0800: SMS Alert for price: 329 
 +++ 2012-02-22 01:26:04 -0800: Email Alert Price changed to 329


What is the purpose of environment.rb and application.rb file?

There are two files where variables and configuration settings are stored. 

- config/environment.rb : Environment settings go here

- config/application.rb : Application level global settings go here

config.time_zone = 'Central Time (US & Canada)'
config.i18n.default_locale = :de
config.filter_parameters += [:password] # ensures that passwords are not logged

The same file is also used for configuring various environment settings such as:

config.action_mailer.smtp_settings # various email settings go here 

What is the purpose of config/environments/development.rb file?

You would specify various config settings the development environment in this file.

 config.action_controller.perform_caching = false # to enable caching

This is because you typically do not want to enable caching in the development environment. 

The same config setting in the production environment would be equal to true. 

How can you define a constant?

Create a new file as shown below under: config/initializers/my_constants.rb

COLORS = ['white', 'red', 'green']

How can you define a custom Exception?


How can you fire a method when a module is included inside a class?

Fire a method inside a class is very simple.

Say you have a module file trig.rb:

module Trig
  PI = 3.141592654
  def Trig.sin(x)
   # ..
  end
  def Trig.cos(x)
   # ..
  end
end

Now you simply import this module inside your class and invoke the method using the “module.method_name” syntax as shown below

require "trig"

class myclass
y = Trig.sin(Trig::PI/4)

This type of invocation ensures that the right module method gets called.

What is the default access modifier (public/protected/private) for a method?

By default all methods are public, except the initialize(constructor) method.

You can make methods private using this declaration within your class:

class MyClass
    def method_public_here
    end
    private# all methods that follow will be made private: not accessible for outside objects
    def method_private_here
    end
  end

How can you call the base class method from inside of its overridden method?

If you are inside the overridden method in the derived class then a simple call to super will call the right method in the base class

class Parent
   def try_this()
      puts "parent"
   end
end

class Child < Parent
   def try_this()
      super()
      puts "child"
   end
end

ch = Child.new
ch.try_this()

This generates the output

parent
child

Now if you just want to call the base class without calling the derived class then the best way to do that is to simply assign an alias to the parent method like this:

class Parent
  def knox
    puts 'parent'
  end
end
 
class Child < Parent
   alias_method :parent_knox, :knox
   def knox
     puts 'child'
   end
end
 
ch = Child.new
ch.parent_knox
ch.knox

This allows you to call the base class method with the alias parent_knox and the derived class method knox can be called directly.

parent
child

Rails Specific Questions

Define the Rails MVC implementation using an example.

What is scope? (or named_scope in Rails 2.x).

Scopes are nothing more than SQL scope fragments. By using these fragments one can cut down on having to write long queries each time you access content.

Say you typically access content as shown below:

@posts = Post.where("published_at IS NOT NULL AND posts.published_at <= "+ Time.now)

Ruby offers you a nice way to put the where condition inside a scope statement as shown below.


class Post < ActiveRecord::Base
  scope :published, lambda { 
    { :conditions =>
      ["posts.published_at IS NOT NULL AND posts.published_at <= ?", Time.now]
    }
  }  
  scope :recent, :order => "posts.published_at DESC"
end

Now you can simply access the published posts as: Post.published

@posts = Post.published

Also, you can access recent posts as 

@recent_posts = Post.recent

Can you give an example of a class that should be inside the lib folder?

Modules are often placed in the lib folder. 


Where should you put code that is supposed to run when your application launches?

In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to require ‘rails/all’ in config/application.rb.

What deployment tool do you use?

Capistrano is a popular deployment tool.

How can you migrate your database schema one level down?

The rake tool does most of the migrations. 

It has this nifty syntax to go back one step:

rake db:rollback

If you want to rollback all the way to the beginning you would use:

rake db:reset

This would drop the database, recreate the Database and load the current schema into it

If you want to rollback multiple steps at the same time you would use:

rake db:rollback STEP=3

To rollback all the way and if you are not worried about losing the data then you can drop the database completely with purge like this:

rake db:purge

What is a sweeper?

Sometimes you want to have control over how often and when the cache expires. 

Sometimes it is a good idea to have the system determine that on a logical basis. Say you have a list of product on your site and you want to reload the cache each time a new product is added/updated/deleted, then you can achieve this by using the sweeper. 

class ProductSweeper < ActionController::Caching::Sweeper
  observe Product# This sweeper is going to keep an eye on the Product model 
  # If our sweeper detects that a Product was created call this
  def after_create(product)
    expire_cache_for(product)
  end
  # If our sweeper detects that a Product was updated call this
  def after_update(product)
    expire_cache_for(product)
  end
  # If our sweeper detects that a Product was deleted call this
  def after_destroy(product)
    expire_cache_for(product)
  end
  private
  def expire_cache_for(product)
    # Expire the index page now that we added a new product
    expire_page(:controller => 'products', :action => 'index')
    # Expire a fragment
    expire_fragment('all_available_products')
  end
end

How can you implement caching in Rails?

Rails offers multiple ways to cache content.

Fragment caching is my favorite because it gives you the choice to fragment to pull a portion from the cache and the remaining from a real-time DB call. 

Say 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 %>

Another technique that works well for static pages is page caching. This technique is often used for home pages and is super fast.

class ProductsController < ActionController
   caches_page:index
  def index
    @products = Products.all
  end
end

What is a filter? When it is called?

Filters are methods that are called either before/after a controller action is called. 

Say a user requests a controller action such as userdashboard/index

In such a case a filter can be setup so that the UserDashboard/index page is only accessible to loggedin users by adding the following lines towards the beginning of the page:

class UserDashboardController < ApplicationController
  before_filter :confirm_logged_in,  :except => [:login, :attempt_login, :logout]
  def index
 ......
  end
After filters are not used too much but they have the effect of executing some code after a particular action has completed. You can use them like triggers.  

What do controllers do in Rails?

Once a request comes into the Rails stack, it goes to the routes table to determine which controller and action should be called. 

Once a controller action is determined the request is routed to the controller and it does the needed processing by connecting with the DB if needed and then it sends control to the View to render the output. 

So, really the flow for Rails goes somewhat like this:

Customer-> Routes-> Controller -> Model(DB) -> Controller -> View -> Customer

How can you divide your controllers into separate modules?


What is RESTful routing?

Routing is fun. If you have ever dealt with IIS you will fall in love with RESTful routing. Here’s how it works. 

Say you want your users to have access to certain pages such as:

/photos/new

/photos/1/edit

/photos/1

And, you want the right controller to get called.

And, you want the right view to get rendered.

All this is made possible with a single entry in the routes.rb file as shown below:

resources :photos 

In Rails, a resourceful route provides a mapping between HTTP verbs and URLs to controller actions. By convention, each action also maps to particular CRUD operations in a database. The single entry in the routing file creates seven different routes in your application, all mapping to the Photos controller:

How can you list all routes for an application?

rake routes -- will display all routes for an application.

How can you send a multi-part email?

Nowadays most email clients support HTML email, however there are still some old Blackberry phones that prefer emails the ‘ol text way. 

Therefore it is important to send emails both as HTML and text. This technique is called multi-part emails. 

The ActionMailer class (included in Rails 3.0) does a great job of sending both text and HTML emails out to the end user at the same time. 

By default Rails sending an email with plain/text content_type, for example:

# app/models/notifier.rb
def send_email(email)
  subject       email.subject
  from          email.from
  recipients    email.recipients
  sent_on       Time.now
  body          :email => email
end

Next let’s update the view in : app/views/notifier/send_email.html.erb

Welcome to here: 

The sent email is a plain text email

Date: Thu, 5 Aug 2010 16:38:07 +0800
From: RailsBP 
To: flyerhzm@gmail.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8

Welcome: http://rails-bestpractices.com

The link url is just displayed as a plain text because of the email content_type.

text/html

If we want the email clients to display link url as html format, we should change the content_type to text/html in the app/models/notifier.rb file

def send_email(email)
  subject          email.subject
  from             email.from
  recipients       email.recipients
  sent_on          Time.now
  content_type     "text/html"
  body             :email => email
end

Now the sent email is a html formatted email

Date: Thu, 5 Aug 2010 17:32:27 +0800
From: RailsBP 
To: flyerhzm@gmail.com
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8

Welcome: http://rails-bestpractices.com

Now the email client can display the link url correctly with html format.

The email header looks somewhat like this:

Content-Type: multipart/alternative;
boundary="----=_NextPart_000_002C_01BFABBF.4A7D6BA0"
Content-Type: multipart/alternative tells the e-mail program to expect different parts to follow, separated by a boundary which specified in quotation marks. Actually the boundary could be anything, though hyphens, equal signs, and underscores insure that the e-mail program won't try to display this boundary to the recipient.
------=_NextPart_000_002C_01BFABBF.4A7D6BA0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

What is the purpose of layouts?

Layouts are partial ruby/html files that are used to render the content pages. 

There are placed in the folder: app/views/layouts

Items that you would typically put in this folder are things like headers/footers, navigation elements, etc.

Here’s a sample layout file: /app/views/layout/application.html.erb

<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Learning System | <%= @page_title || 'Admin Area' %></title>
    <meta name="author" content="Anil Punjabi">
    <%= stylesheet_link_tag('public', 'admin', :media => 'all') %>
    <%= javascript_include_tag('application') %>
  </head>
  <body>
    <div id="header">
      <h1>Learning System</h1>
    </div>
    <div id="main">
      <% if !flash[:notice].blank? %>
      <div class="notice">
        <%= flash[:notice] %>
      </div>
      <% end %>
      <div id="content">
        <%= yield %>
      </div>
    </div>
    <div id="footer">
      <p id="copyright">&copy; / Anil Punjabi</p>
    </div>
  </body>
</html>
Say you are trying to access the page as shown below:
Then the contents of the index.html.erb would be placed above in the section shown under <% yield %> above and sent back to the user.

Is it possible to embed partial views inside layouts? How?

That is the purpose of layouts. You embed partial views inside the file /app/views/layout/application.html.erb and then whenever you render any page this layout is merged with it.

What is the purpose of RJS?


How can you create a REST API for your application?

How can you define a new environment called ‘staging’?

What is Rake?

Rake is a popular ruby gem that makes the job of running tasks simpler. 

Rake is most often used for DB tasks, but it can be used for m

The common DB commands are:

rake db:migrate
rake db:reset

You can use cron to schedule rake tasks. 

Sometimes you would create a dataloader.rake file and put it in the lib/tasks folder so that it can be used to populate the database on startup.

What is Capistrano?

Capistrano is a popular deployment tool — it allows developers to push code from their desktop to the servers. 


What is a polymorophic association?

How can you implement a polymorphic association?

What is a has and belongs to many association?

What is the difference between has_one and belongs_to?

How can you implement single table inheritance?

What is eager loading?

Eager loading is a great optimization strategy to reduce the number of queries that are made against the DB.

Say you are finding 10 employees and then you are looking for their post codes. Then your query would appear something like this:

clients = Client.limit(10)
clients.each do |client|
  puts client.address.postcode
end

This may seem fine at first look but really this implementation leaves much to be desired. It makes 11 DB calls just to get the results.

Now you can optimize this query by making a slight change in the request like this:

clients = Client.includes(:address).limit(10)
clients.each do |client|
  puts client.address.postcode
end 

This new request makes two SQL calls like this:

SELECT * FROM clients LIMIT 10
SELECT addresses.* FROM addresses
    WHERE (addresses.client_id IN (1,2,3,4,5,6,7,8,9,10))
So, as you can see it really loads a lot more upfront and therefore it is called eager loading.
 

How can you eager load associated objects?

How does validation work?

Validation means checking to see if data  is good before it is stored in the database.

During signups and other such user input cases you want to check and be sure that the data is validated. In the past developers would often put this type of validation logic as triggers in the database.  

In an MVC architecture one can do validations at each level. 

You can do validations in the controllers but it is usually a good idea to keep your controllers skinny.

Views suffer from the javascript limitation because javascript can be disabled on the client side so they are not completely reliable.

The best way to manage validation is to put it in the model code. This model code is really the closest as you can be to the database and works very well for Rails applications.

Here are a few validation examples:

class Person < ActiveRecord::Base
  validates :name, :length => { :minimum => 2 }
  validates :points, :numericality => { :only_integer => true }  # only integer
  validates :age,  :numericality => { :greater_than => 18 } # greater than 18
  validates :email, :uniqueness => true
  validates :email, :confirmation => true  # this is to validate that the two email fields are identical
  validates :email_confirmation, :presence => true # this is to validate that the email confirmation field is not nil

In your view template you may use something like this:

 <%= text_field :person, :email %> <%= text_field :person, :email_confirmation %>

How can you add a custom validation on your model?

Now custom validations takes it to the next step.

Say you want to confirm that the data meets certain criteria 

How can you implement a custom theme for your forms?

Why is fields_for used for?

What is the purpose of a helper method?

What is flash?

Flash  is simply a way to pass some value to the next action. 

Anything you place in the flash will be exposed to the very next action and then cleared out.

Here’s an example:

   def destroy       section = Section.find(params[:id])       section.destroy       flash[:notice] = "Section destroyed."      redirect_to(:action => 'list', :page_id => @page.id)     end

Then wherever you want to use the flash you can write this code. I often put this snippet in the application.html.erb file, somewhere towards the top:

   <% if !flash[:notice].blank? %>          <div class="notice">    <%= flash[:notice] %>


How can you install the missing gems that are required by your application in the simplest way?

bundle install

This command will install all dependencies and missing gems. It looks at your Gemfile to figure out what gems are needed by your application. 

How can you implement internationalization?

Ruby ships with i18n which is an internationalization gem. 

You need to create locale files and save them under the config/locales directory as:

en.yml

es.yml

fr.yml

The keys should match for each of these files. 

en:   main_page:     hello: “Hello”     welcome: “Welcome to   My Company” es:   main_page:     hello: “Hola”     welcome: “Bienvenido a Mi Empresa” fr:   main_page:     hello: “Salut”     welcome: “Bienvenue à  Mon Entrepriseâ€

 In your code you would need to specify that the text would be locale specific. So change it to something like this:

.content   %h1     = t("main_page.hello")   %p     = t("main_page.welcome") Then you have to select the actual locale, which the users can do from a menu option. 

More details here

How can you configure your application for different environments?

How can you instruct rails logger to ignore passwords and such fields while logging?

Test Frameworks

Ruby on Rails has a number of built-in and a few other third-party test frameworks. Here are a few sample questions on such frameworks:

Are you familiar with unit testing?

How does functional testing differ from unit testing?

Have you ever used a mocking framework?

Are you familiar with BDD using RSpec or Cucumber?

What is an alternative to using test fixtures?

How can you reuse part of a text fixture?

How do you specify associations in the test fixture yml files?

Plugins

Plugins are the principal mechanism to reuse code. The open-source community is at full-bloom when it comes about plugins. The Rails Plugins site has a really good list of such plugins from the community.

What plugin would you recommend for user authentication and authorization?

Devise works great with Rails. 

It supports OAuth authentication and therefore integrates nicely with Facebook. 

What plugin do you use for full-text search?

Sunspot supports full-text search capability and uses Solr as the back-end search engine to do so. 

You would include these two plugins in your gem file as shown below:

gem 'sunspot_rails' 
gem 'sunspot_solr' 

More details here


How can you implement a state machine?

What is the difference between a plugin and a gem?

A gem is just ruby code. It is installed on a machine and it’s available for all ruby applications running on that machine.

Rails, rake, json, rspec — are all examples of gems. 

Plugin is also ruby code but it is installed in the application folder and only available for that specific application. 

Sitemap-generator, etc.

In general, since Rails works well with gems you will find that you would be mostly integrating with gem files and not plugins in general. Most developers release their libraries as gems. 

How can you create a plugin?

You can read about how to create a rails plugin here:

Plugin Guide

How can you implement a search feature that searches for multiple models?

If you are using acts_as_solr for your search you will be able to use multi_solr_search to enable search across multiple models. 

Also, you can configure Sunspot/Solr to support search across multiple models. Here’s a post about it

Sphinx, another powerful search server can be used to search across multiple models and it works great. 


How can you upload a file to a server?

Paperclip is the best solution to manage file uploads to a server.

It can also help you with multiple file uploads and associate it with ActiveRecord.

There are also good examples online that show how you can make rotating sliders with the paperclip images.

Another nice solution is using carrier_wave gem. 

The nice thing about carrier_wave is that it has good documentation on how to integrate with S3, Google & Rackspace for file storage.

You can achieve the same file storage capability with Paperclip as well though. 

SEO Related Questions

How can you generate sitemaps for your Rails site?

You can use dynamic_sitemaps gem to generate sitemaps

How can you show search user friendly urls instead of using only numeric ids?

The simplest way to do this is to use the gem FriendlyID.

It gives you the ability to specify a friendly URL for pages so that instead of the standard page URLs like:

http://mysite.com/page/1

You can build pages such as:

http://mysite.com/page/my-awesome-page-about-articles-and-content

How can you create page titles and metadata for your pages?

You can use the Headliner plugin for adding page titles.

You can use the MetaMagic plugin to add meta tags.

How can you create breadcrumbs on your pages?

Gretel is a great plugin to introduce breadcrumbs in your Rails application.

Another very simple implementation is breadcrumb_on_rails.


Architecture Related Questions

This questions can be from different angles like: quality, security, scalability, manageability, interoperability, reusability and all the other ilities you name! Here are a few example questions:

Is Rails scalable?

Yes Rails gives you complete freedom to use all traditional means of scaling an application. Things like memcached, caching full pages, caching fragments are all supported. 

You can use any standard CDN to serve your media and static content as well. 

Database scaling using sharding is supported. 

Finally heroku makes your life easier by giving you the flexibility to scale up/down based on your need. Mostly websites have a peak time during which you need more servers and then there is a sleep time. Heroku makes that on-demand scaling process simpler. Companies such as HireFireApp.com makes the autoscale process easier.


What are the key deployment challenges?

heroku makes deployment easy.

Things that I sometimes run into are:

> Mismatched gem versions between local and production environment

> Some lessons learned:

»» Use image_tag helper each time

»» Specify root path in ENV variable

»» Configure assets pipeline by setting: config.assets.enabled = true in the config/application.rb file

Configure Capistrano script to precompile assets 

Here’s a nice video about Assets Pipeline

How can you safeguard a rails application from SQL injection attack?

Rails already has the logic built into it to prevent SQL injection attacks if you follow the right syntax. 

Say you are trying to authenticate a user based on their login and password you might be tempted to use a syntax as below:

User.first("login = '#{params[:name]}' AND password = '#{params[:password]}'")

If an attacker enters ’ OR ‘1’=‘1 as the name, and ’ OR ’2’>’1 as the password, the resulting SQL query will be:

 SELECT * FROM users WHERE login = '' OR '1'='1' AND password = '' OR '2'>'1' LIMIT 1 

This will simply find the first record in the database, and grants access to this user.

To prevent this type of SQL injection simply use the following format.

  User.where("login = ? AND password = ?", entered_user_name, entered_password).first

OR

User.where(:login => entered_user_name, :password => entered_password).first

How can you secure a rails application?

Rails has a lot of in-built capabilities to deal with common web-security issues. 

> SQL Injection

> Cross-Site 

> Session fixation and Session hijacking

> Captcha

Follow this useful security guide

How can rails engage with a SOA platform?


Overall Community Questions

Can you tell me a few good community resources for Rails?

Stackoverflow, Github, various Meetup groups

Where would you reach out to get the community to answer your questions?

Stackoverflow and meetup groups.


Which famous applications are built using ruby on rails?

Basecamp

Shopify

When should you not use Ruby on Rails for a startup?

Let me start with the bad rap you might have heard about RoR first. 

Rails makes development go faster because you have to write less code to achieve the same functionality. This require a deeper understanding of how Rails does what it does. This might be a challenge for some developers that are proficient if either the back-end or the front-end, but not both.

Also, Rails is slow if you don’t tune it right. 

Some people complain that the Rails syntax is complicated. Yes it appeared to be a bit wonky in the first couple of months to me as well. 

After that digestion period though, development will fly. The flexibility and structure that Rails offers you will make adding new features a lot easier. 

This flexibility is often a desired capability for startups as they often need to tune their offering based on customer feedback. 

If you are building a startup where you can get by with using regular CMS systems (like Wordpress) or standard eCommerce platforms then you don’t need to worry about Rails.

If you are developing a platform from the ground up give Rails a chance.

More answers on Quora

When should you not use Ruby on Rails for a startup?

How to time a Product Launch if your competitor has a superior product?

Wait for your competitor to make their announcement and then schedule your Product launch. 

The advantage you have now is that you hold all the cards. 

a) You can spin the product offering and tout other benefits of your product offering like: Customer service, platform stability, engagement metrics. You can also offer a peek preview of a bigger launch 6 months down the line.

Learn from other company launches like all those other smartphones vs iPhone:

http://slumz.boxden.com/f244/sma…

c.) Reduce the price slightly to appear competitive. You could also offer a discount for a short time. Like Sprint does when they offer an unlimited data plan as compared to AT&T and Verizon.


d.) Delay the launch by a couple weeks and take this time to learn about your competitor’s weaknesses. Here’s how this would work. A large number of customers might try your competitor’s solution as soon it is launched. Then their weakness would quickly spread in the market. Use this information and frame your marketing message accordingly.

e.g. Say you are Samsung and your competitor is Apple. Apple is launching the iPhone 4. In this scenario, a lot of people would purchase the product and quickly report the antennae problem. 

So, you would listen to the market and then time your launch with a big BOLD message: “We make smartphones too.”, with a hint of Apple’s antennae problem in the backdrop.

When Toyota’s Prius started having problems every car company capitalized on Prius’ weakness. 
Enjoy this SNL video:
http://www.dailymotion.com/video…

Like I said you hold all the cards. 

Game on !!!