Wednesday, 2 August 2017

Rails 5.1 with webpack and api-ai SDK

Here we are going to see how to use webpacker with rails application and adding one javascript SDK with rails application.

Webpack

Here webpack takes modules with dependencies and generates static representing those modules.

reference link

https://webpack.github.io/docs/what-is-webpack.html



Let we start with step by step Processes


a.Create new rails repo with webpacker
rails new myapp --webpack

b. File called package.json is created inside the myapp(rails repo) with content


{
  "name": "chat_bot",
  "private": true,
  "dependencies": {}
}

c. Add required javascript lib inside the  package.json under 
dependencies. 
here we are adding the api.ai SDK into package.json

ex: 

{
  "name": "chat_bot",
  "private": true,
  "dependencies": {
    "api-ai-javascript" : "~> 2.0.0-beta.21"}

}

d. Once this added please run npm install at myapp(rails repo) 
directory level. 

e. Make sure to require "api-ai-javascript"  at application.js or 
where ever you required.

f. Now javascript web SDK for API.ai is available throughout the project


Note : If you are using less then the rails5.1 then the way of 
adding the SDK will be different. Please look into reference link. 

Reference link

https://github.com/rails/webpacker

https://github.com/api-ai/apiai-javascript-client


Sunday, 30 July 2017

Rails5 application with Push Notification using FCM for Android

Part One for Android

Gem used
a.fcm

Support

a. Android
b. IOS


Here we are going to see how push notification can be sent to android using fcm. Same fcm gem can be used for ios as well.

a. Add it to gem file and run bundle


#for push notification for ios and android 
 gem 'fcm'


b. Next add project to firebase 
(mobile developers will understand the process)

  1. visit https://console.firebase.google.com
  2. create a new project with required info(ex: project name)   
  3. Asks for  
      a.Add Firebase to your iOS app
      b.Add Firebase to your Android app
   here we go with android and fill the fields 
      a. Android package name
      b. Download config file
      c. Add Firebase SDK   
   Please do all required steps to get
      a. Server key   
      b. Legacy server key
      c. registration_ids/device token of every user who receives 
         the push notification  
 
c. Here i'm writing push notification as a separate service.Basically
 an api service. So my code goes here 

 /controller/api/PushNotifiactionService/push_notification.rb


  
require 'fcm'
fcm = FCM.new("Legacy server key") Ex: AIzaSydsfds324asfdsfdsf
# get it from project settings - cloud messaging 
registration_ids= ["fgf4yaJ64E:APA91bfsfds...", "EaIbj_2oGkR7JXi..."]  
#mobile end will provide you the ref_ids to whom shoulbe received
options = {data: {student_count: "50"}, collapse_key: "updated_count"}
#message content to sent in push notifiaction
response = fcm.send(registration_ids, options)
#sending push notifaiction

d. Add it to config/application.rb
config.autoload_paths += %W(#{config.root}/app/controllers
/PushNotificationService/PushNotification)
That's it



Reference Link :

a. https://github.com/spacialdb/fcm

Tuesday, 14 July 2015

Choose the right call backs in rails. (an example by comparing after_create and after_commit)


 We get into the situation where incident object need to created/saved with before_save and after_create/after_commit.  
 first attempt [ incident object with before_save and after_create]  
 incident have an attribute called status.  
 before_save  
 def build_incident_logs  
    self.event_logs.build if status_changed?  
 end  
 incident object  
 incident.save  
 after_create  
 def update_attribute_of_incident  
    self.attribute_one = value    
    binding.pry  
    self.save!  
 end  
 a.Start the server begin the process, first it comes to before save and build the incident logs.  
 b.Then incident will be created.  
 c. After create is called and while trying to update attribute of incident, before save is called again. Now code inside before_save look for status changes.  
 4. All this happen inside same transaction.  
 5. So self.id_was nil. Again it will create an duplicate data in incident logs  
 I have attached the screen shot of this for better understand.  
 
Second attempt [ incident object with before_save and after_commit] Now change after_create to after_commit before_save def build_incident_logs self.event_logs.build if status_changed? end incident object incident.save after_commit def update_attribute_of_incident self.attribute_one = value binding.pry self.save! end a.Start the server begin the process, first it comes to before save and build the incident logs. b.Then incident will be created. c. After create is called and while trying to update attribute of incident, before save is called again. Now code inside before_save look for status changes. 4. Because of after_commit, it will start the new transaction and previous transaction was closed. 5. Status is available. 6. If i request for self.id_was some_id (eg:34). so no duplicate data is created at incident logs.
Conclusion: Above content will helpful to pick the right call backs based on requirement. after_create will look into same transaction but after_commit will begins from new transaction .

Friday, 8 May 2015

What is new in rails4?

 Source : http://railscasts. Com/episodes/400-what-s-new-in-rails-4? View=asciicast  
 1. Concerns - http://stackoverflow. Com/questions/14541823/how-to-use-concerns-in-rails-4  
 2. Console-specific configuration here such as using pry  
 3. Postgress  
 rails 4 has support for native datatypes in postgres and we’ll show two of these here, although a lot more are supported: array and hstore. We can store arrays in a string-type column and specify the type for hstore.  
 4. New activerecord features  
 a. All method. This now returns an activerecord relation instead of an array of results which means that it’s now lazily loaded and only triggers a database query when it needs to. This also gets rid of the need for the scoped as it replaces this functionality  
 b. Load method - this will trigger the database query but return an activerecord relation instead of an array of results.  
 c. None method - which will return a activerecord relation with no records  
 d. Speaking of scopes, we can now call not on the where scope to invert it.  
 e. The order clause now accepts a hash so we can pass in a column name and the order that we want the results to be in. We can also pass in multiple column names to order by multiple columns.  
 f. Another useful new method is find_by. We’ve always been able to use dynamic finders, such as find_by_name, but these rely on method_missing and the implementation isn’t very clean. Rails 4 introduces a find_by method that we can pass a hash to, like this:  
 >> article. Find_by name: "hello"  
 5. Activemodel::model  
 6. Public/index. Html : this means that we no longer have to delete the public/index. Html  
 7. Gemfile changes  
 new default gem  
 1. Sprockets-rails  
 2. Turbolinks  
 8. Controller  
 a. Before_filter -> before_action  
 b. The next thing of note is that the update action now responds to either a put request or a patch request.  
 c. Update_attributes method-> update  
 d. Strong parameters built in replaces attr_accessible.  
 9. Scope syntex change  
 class article < activerecord::base  
  scope :sorted, order(:name)  
 end  
 class article < activerecord::base  
  scope :sorted, -> { order(:name) }  
 end  
 10. Changes to views  
 a. Lot of new helper methods  
 collection_select helper method aready exist  
 collection_check_boxes and collection_radio_buttons to generate lists of checkboxes or radio buttons for an association  
 there are also helper methods for the different html 5 input types.  
 b. Template handlers  
 c. Cache digest  
 11. Routes. Rb  
 concern  
 /config/routes. Rb  
 resources :articles do  
  resources :comments  
 endresources :photos do  
  resources :comments  
 end  
 ----------------------------  
 concern :commentable do  
  resources :comments    
 end  
 resources :articles, concerns: :commentable  
 resources :photos, concerns: :commentable  
 b. Match method depricated.  
 c.  
 get 'foo', to: 'articles#index', constraints: {protocol: "https", subdomain: "test"}  
 "https://test. Example. Com/foo"  
 12.  
 /config/environments/production. Rb  
 config. Eager_load = true  
 previously this behaviour was enabled using an option called threadsafe!  
 13. Testing  
 a. Instead of having unit and functional directories we have controllers, models and so on making it structured more like rspec is. Also, this now uses minitest.  
 b. This now has a different look and if a routing error is thrown it shows a list of the valid routes which is useful.  
 c. /rails/info path.  
 there were several things that were removed from rails 4 such as  
 activeresource, model observers, page and action caching and disabling rack::cache  
  by default. All of these can be brought back by using various gems if  
 you can’t live without them. One feature that we haven’t covered here is  
  actioncontroller::live. This will be covered in detail in a  
  future episode as it’s big enough to deserve one to itself. If you were  
  expecting a queueing api with asynchronous mailing support this has  
 been pulled from rails 4. 0 but should be included in rails 4. 1.   

Monday, 1 September 2014

Generate or use generated graph inside pdf (prawn gem)

List of gems available for graph generation inside pdf or after generation can be 
shown inside pdf. By using cron job can frequently clean the directory to avoid memory problem.    
 
 prawn-graph - https://github.com/HHRy/prawn-graph/  
 gruff - https://github.com/topfunky/gruff  
 prawn_charts - https://github.com/MrPowers/prawn_charts   
 Using GChart with Prawn - http://pagodaworks.com/2013/10/16/using-gchart-with-prawn/   
 Prawn::Graph - Simple Graphing for Prawn  
 (http://ryanstenhouse.eu/projects/2010/02/12/prawn-graphs-simple-graphing-for-prawn/)
 (http://www.ruby-doc.org/gems/docs/p/prawn-graph-0.0.4/index.html)  

Wednesday, 27 August 2014

Web development discussion,ror question and answers

server question and answers  
 1.difference between application server and web server  
 
ruby questions and answers  
 
1.difference between module an class  
 You might also use a module when you have shared methods across multiple apps.   
             ¦ class               ¦ module                                ¦  
 ¦---------------+------------------------------------+-----------------------------------------------------------------------¦  
 ¦ instantiation ¦ can be instantiated        ¦ can't be                               ¦  
 ¦ usage     ¦ object creation          ¦ mixin facility. provide a namespace.                 ¦  
 ¦ superclass  ¦ module               ¦ object                                ¦  
 ¦ consists of  ¦ methods, constants and variables  ¦ methods, constants and classes                    ¦  
 ¦ methods    ¦ class methods, instance methods  ¦ module methods, instance methods                   ¦  
 ¦ inheritance  ¦ inherits behavior and can     ¦ No inheritance                            ¦  
 ¦        ¦  be base for inheritance     ¦                                    ¦  
 ¦ inclusion   ¦ can't be included         ¦ can be included in classes/modules by using the include command    ¦  
 ¦        ¦                  ¦  (includes all instance methods as instance methods in class/module) ¦  
 ¦ extension   ¦ can not extend with extend command ¦ module can extend instance by using extend command (extends given   ¦  
 ¦        ¦  (only with inheritance)     ¦  instance with singleton methods from module)            ¦  
 +----------------------------------------------------------------------------------------------------------------------------+  
 Classes are simply like Java classes.  
 Modules are like Java static classes. Think about Math class in Java. You don't instantiate it, and you reuse the methods in the static class (eg. Math.random()).   
 
2.return types in ruby method  
 1. default return last value  
 2. explicitly value can also be returned.  
 3. only one return statement can be used  
 4. with one return statement multiple values can be sent.   

 3.class level methods and object methods  
 (www.railstips.org/blog/archives/2009/05/11/class-and-instance-methods-in-ruby/)  
 Class and Instance Methods in Ruby  
 Class methods are methods that are called on a class and instance methods are methods that are called on an instance of a class. Here is a quick example and then we’ll go into a bit more detail.  
 class Foo  
  def self.bar  
   puts 'class method'  
  end  
  def baz  
   puts 'instance method'  
  end  
 end  
 Foo.bar # => "class method"  
 Foo.baz # => NoMethodError: undefined method ‘baz’ for Foo:Class  
 Foo.new.baz # => instance method  
 Foo.new.bar # => NoMethodError: undefined method ‘bar’ for #<Foo:0x1e820>  
 See the difference? bar is a class method, so calling bar on the Foo class works fine. baz is an instance method, so calling baz on the Foo class raises a NoMethodError. Then, on the next couple lines, we call both methods on an instance of Foo (Foo.new).  
 Now that we have a base, let’s show a few of the ways you can create class and instance methods and examples of what they would be used for.  
 Class Methods  
 Ruby is very flexible and as such it allows several ways to define a class method. The following is a sample of the most commonly used ways.  
 # Way 1  
 class Foo  
  def self.bar  
   puts 'class method'  
  end  
 end  
 Foo.bar # "class method"  
 # Way 2  
 class Foo  
  class << self  
   def bar  
    puts 'class method'  
   end  
  end  
 end  
 Foo.bar # "class method"  
 # Way 3  
 class Foo; end  
 def Foo.bar  
  puts 'class method'  
 end  
 Foo.bar # "class method"  
 The first way is my preference. When I see self.method_name it is immediately apparent to me that this is a class method. A lot of people use way #2 and it is pretty heavily used in Rails.  
 There is nothing wrong with it, but when you have a class with a lot of class methods in a class << self block, it can be hard to tell if the method is a class or instance method because it is defined the same (def bar). If this doesn’t make sense, feel free to use it for a while and you’ll probably run into what I’m talking about.  
 Way 3 is not that common as far as I have seen and is more often a way to quickly add methods on the fly to a class. These are not the only three ways to define class methods, but they seem to be the ones that I see the most.  
 So when would you use a class method? Class methods are for anything that does not deal with an individual instance of a class. ActiveRecord::Base#find is one example. If you look in ActiveRecord::Base, you’ll see something like this:  
 module ActiveRecord  
  class Base  
   # some stuff  
   class << self  
    def find(...)  
     # blah  
    end  
   end  
  end  
 end  
 Looks familiar, eh? Some other uses of class methods in Rails are validations and associations in ActiveRecord and before/after/around filters in ActionPack. The way this works is something like this (simplified for clarity):  
 module ActiveRecord  
  class Base  
   def self.validates_presence_of(...)  
    # make sure present  
   end  
  end  
 end  
 class Foo < ActiveRecord::Base  
  validates_presence_of :bar  
 end  
 When you say validates_presence_of, the class method in AR::Base is what gets called.  
 Instance Methods  
 Enough about class methods, lets move on. Instance methods are a bit more simple. Here are a few common ways that instance methods are defined.  
 # Way 1  
 class Foo  
  def baz  
   puts 'instance method'  
  end  
 end  
 Foo.new.baz # "instance method"  
 # Way 2  
 class Foo  
  attr_accessor :baz  
 end  
 foo = Foo.new  
 foo.baz = 'instance method'  
 puts foo.baz  
 # Way 3  
 class Foo; end  
 foo = Foo.new  
 def foo.bar  
  puts 'instance method'  
 end  
 Foo.new.baz # "instance method"  
 The key difference is instance methods only work with an instance and thus you have to create a new instance to use them (Foo.new). Again, there are more ways to define instance methods than this, especially if you look into meta programming.  
 So what are some examples uses of instance methods in Rails, to give you a better idea? Ever do a find in a destroy action and then call destroy on the found instance? destroy is an instance method.  
 class FoosController < ActionController  
  def destroy  
   foo = Foo.find(params[:id])  
   foo.destroy  
   redirect_to foos_url  
  end  
 end  
 So are save and update_attributes, which you have definitely used before if you’ve done any Rails.  
 foo = Foo.new(:title => 'Bar')  
 foo.save # is an instance method  
 
4.how to tranafer values between methods  
 (http://praaveenvr.blogspot.in/2014/03/ruby-on-rails-how-to-pass-variable.html)  
 If you want to share the value across the methods of a same controller instance then, declare an instance variable:  
 class BarsController < UsersController  
 before_filter :init_foo_list   
 def method1   
  render :method2   
 end   
 def method2   
  @foo_list.each do | item|   
  # do something   
  end   
 end   
 def init_foo_list   
  @foo_list ||= ['Money', 'Animals', 'Ummagumma']   
 end  
 end  
 If you want to share the value across two controllers withn a session, then:  
 class BarsController < UsersController  
 before_filter :init_foo_list   
 def method1   
  render :controller => "FoosController",   
  :action => "method2"   
 end   
 def init_foo_list   
  params[:shared_param__] ||= ['Money', 'Animals', 'Ummagumma']   
 end   
 end  
 class FoosController < UsersController   
 def method2   
 params[:shared_param__].eachdo | item|  
  # do something   
   end   
 end 2.return types  
 end  
 
5.Abstract classes & Interfaces  
 There is no concept of abstract class and interface in ruby.   
 Another way to look at this issue is to think  
 of static typing as working like an aristocracy: Statically typed languages are constantly asking about your parent or grandparent, or perhaps, in the case of Java-style interfaces, your aunts and uncles. In a statically typed language, an objects family tree matters deeply. Dynamically typed languages, by contrast, are meritocracies:Types, Safety, and Flexibility  
 They are concerned with which methods you have, rather than where those methods came from. Dynamically typed languages rarely ask about an objects ancestry; instead, they simply say, I dont care who you are related to, Mac. All I want to know is what you can do.  
 
6.why ruby doesn't support multiple inheritance?

  
 7. Multiple inheritance in ruby
   Both Java and Ruby doesn't support multiple inheritance. Where in Ruby we can achieve multiple inheritance by including multiple modules. this concept is called mixin.  
 
8.keywords in ruby  
 The keywords are not objects but defined in the parser which can be found in parse.y in the Ruby source. Here's the relevant part from that file:  
 reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__ | keyword_BEGIN | keyword_END | keyword_alias | keyword_and | keyword_begin | keyword_break | keyword_case | keyword_class | keyword_def | keyword_defined | keyword_do | keyword_else | keyword_elsif | keyword_end | keyword_ensure | keyword_false | keyword_for | keyword_in | keyword_module | keyword_next | keyword_nil | keyword_not | keyword_or | keyword_redo | keyword_rescue | keyword_retry | keyword_return | keyword_self | keyword_super | keyword_then | keyword_true | keyword_undef | keyword_when | keyword_yield | keyword_if | keyword_unless | keyword_while | keyword_until ;  

9.difference between each and map   
 each simply iterates over the given enumerable, running the block for each value. It discards the return value of the block, and each simply returns the original object it was called on:  
 [1, 2, 3].each do |i| i + 1 end # => [1, 2, 3]  
 This is simply a nicer, more universal way of doing a traditional iterating for loop, and each is muchpreferred over for loops in Ruby (in fact, I don't think I've ever used a for loop in Ruby).  
 map, however, sets the current element being iterated over to the return value of the block, and then returns a new object with those changes:  
 [1, 2, 3].map do |i| i + 1 end # => [2, 3, 4]  
 So it "maps" each element to a new one using the block given, hence the name "map".  
 
10.mixins  
 1.Inside module creating object methods and this module is inherited(multiple inherited) by other classes.   
 2.So this module is available as class to the other class.  
 3. Module allowing other class to access its object method.  
 4. This is the reason behind the name 'mixins'    
 5.mixture of module,class,object method   
 
11.Difference between render and redirect_to   
 (http://stackoverflow.com/questions/7493767/are-redirect-to-and-render-exchangeable)  
 
12.difference between require an include  
 (http://ionrails.com/2009/09/19/ruby_require-vs-load-vs-include-vs-extend/)  
 The require statement is similar to the include statement of C and C++ and the import statement of Java. If a third program wants to use any defined module, it can simply load the module files using the Ruby require statement:  
 ex:  
 require "Week"  
 class Decade  
 include Week no_of_yrs=10 def no_of_months puts Week::FIRST_DAY number=10*12 puts number end  
 end  
 d1=Decade.new puts Week::FIRST_DAY Week.weeks_in_month Week.weeks_in_year d1.no_of_months  
 
13.module inside the class an class inside the module  
14.relationships in sql  
15.relationships in mongodb  
16.difference between mongodb and mongoid/mango mapper  
17. Agile development  
        1.pair programming  
        2.knowledge transfer  
        3.code re-factoring  
        4.daily stand up meets  
        5.no overtime  
        6.Continuous integration   
        7.story based or module based work(some times order of work/task execution)  
        8.User stories and users choosing a deck for next release  
        9.Small releases  
        10.Coding standards  
        11.Continuous iterations  
        12.test driven development  
        13.extreme programming  
        14.Tests first when find bugs  
        15. UML based approach  
 Scrum: A key principle of Scrum is its recognition that during a project the customers can change their minds about what they want and need (often called requirements churn), and that unpredictable challenges cannot be easily addressed in a traditional predictive or planned manner. As such, Scrum adopts an empirical approach—accepting that the problem cannot be fully understood or defined, focusing instead on maximizing the team's ability to deliver quickly and respond to emerging requirements.  
 the top 10 most effective agile practices (as reported by respondents) were:  
   Continuous Integration  
   Daily Stand Up Meeting  
   Developer TDD  
   Iteration Planning  
   Code Refactoring  
   Retrospectives  
   Pair Programming  
   Active Stakeholder Participation  
   Potentially Shippable Software  
   Burndown Tracking  
  Nobody used pair programming except in panic situations (major bug fix in zero time), managers still just don't buy into the idea at all - and I'm talking AT ALL, which is a shame as I quite like it. User stories and users choosing a deck for next release - doesn't really work unless the users really really buy in, which I've not seen yet. Users in my area always say that everything is of top importance,  they cannot live without any of it. I personally just rephrase into "what order should I personally work on these tasks in your opinion?".  
   Test driven dev - very little of this happens, but a lot of unit tests get written (after the code does though), so a near miss imho  
 Continuous integration - this is highly dependent on the team, in last 5 years all my teams had it, but it often lapsed (broken build) for days/weeks at a time before it got attention. A lot of people still don't buy into this.  
 Refactoring often - this is actually getting some serious buy-in. Refactoring is a skill that if you don't have is likely to be a serious problem.  
 Small releases - this (in my work) is generally the norm anyway, although probably being done  
 Coding standards - yes  
 Collective code ownership - blame is still pretty much rife, and often a "bad" module never really gets fixed cos the coder that produced it just fixes and fixes it till it "works".  
 No overtime - nearly, but highly dependent on the team lead - I've seen the worst stuff (death marches) going on within a few feet of my team...  
 Tests first when find bugs - this happens in my experience. Is a very good thing.  
 18. ORM  
 ORM is Object Relational Mapper. It means you don't have to manually call the database yourself; the ORM handles it for you.  
 Ruby on Rails uses one called ActiveRecord, and it's a really good one.  
 ORM allows you to do things such as:  
 User.find(50).contacts  
 Instead of manually writing a SELECT statement with JOINs, WHEREs, etc.  
 ex : JAVA  
 (http://stackoverflow.com/questions/7493767/are-redirect-to-and-render-exchangeable)  
 19. when,where to use object,class variables?  
 http://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/113-class-variables  
 class Planet  
  @@planets_count = 0  
  def initialize(name)  
   @name = name  
   @@planets_count += 1  
  end  
  def self.planets_count  
   @@planets_count  
  end   
 end  
 Planet.new("earth"); Planet.new("uranus")  
 p Planet.planets_count  
  stdout:  
  2  
 class ApplicationConfiguration  
  @@configuration = {}  
  def self.set(property, value)  
   @@configuration[property] = value  
  end  
  def self.get(property)  
   @@configuration[property]  
  end  
 end  
 class ERPApplicationConfiguration < ApplicationConfiguration  
 end  
 class WebApplicationConfiguration < ApplicationConfiguration  
 end  
 ERPApplicationConfiguration.set("name", "ERP Application")  
 WebApplicationConfiguration.set("name", "Web Application")  
 p ERPApplicationConfiguration.get("name")  
 p WebApplicationConfiguration.get("name")  
 p ApplicationConfiguration.get("name")  
  stdout:  
 "Web Application"  
 "Web Application"  
 "Web Application"  
 class Foo  
  @foo_count = 0  
  def self.increment_counter  
   @foo_count += 1  
  end  
  def self.current_count  
   @foo_count  
  end   
 end  
 class Bar < Foo  
  @foo_count = 100  
 end  
 Foo.increment_counter  
 Bar.increment_counter  
 p Foo.current_count  
 p Bar.current_count  
  stdout:  
 1  
 101  
 
20. modules  
 a.Modules provide a namespace   
 b.Modules implement the mixin facility.  
 namespace :  
 module Trig    
 PI = 3.141592654    
 def Trig.sin(x)    
  # ..    
 end    
 def Trig.cos(x)    
  # ..    
 end   
 end  
 module Action  
   VERY_BAD = 0    
   BAD   = 1    
 def Action.sin(badness)    
  # ...    
 end   
 end  
 require "trig" require "action"  
 y = Trig.sin(Trig::PI/4) wrongdoing = Action.sin(Action::VERY_BAD)  
 mixin   
 
21.Why Ruby Does Not Support Method Overloading?  
 There may be only one method with given name in Ruby class. If several methods with the same name defined in the class - the latest overwrites previous definitions.  
 However, you may emulate methods overloading like this:  
 class Person   
  def print_details(*args)  
  case args.size  
 when 1 "Hey My Name is #{args[0]}" when 2 "Hey My Name is #{args[0]} and #{args[1]}" end   
 end end  
 
22. access specifiers in ruby  
23.difference symbol ans string  
 
Rails questions and answers  

 1.Difference between plugin and gem  
 2.Defference between gem in vender/gems and gems  
 3.rake routes GET POST DELETE (HTTP request method)?  
 (HTTP request method)?  
 GET  
 POST  
 PATCH ( previous versions of Rails used PUT in place of PATCH)  
 DELETE  
 The hypertext transfer protocol (HTTP) defines the basic operations GET, POST, PATCH, andDELETE. These refer to operations between a client computer (typically running a web browser such as Firefox or Safari) and a server (typically running a web server such as Apache or Nginx). (It’s important to understand that, when developing Rails applications on a local computer, the client and server are the same physical machine, but in general they are different.) An emphasis on HTTP verbs is typical of web frameworks (including Rails) influenced by the REST architecture, which we saw briefly inChapter 2 and will start learning about more in Chapter 7.  
 GET is the most common HTTP operation, used for reading data on the web; it just means “get a page”, and every time you visit a site like google.com or wikipedia.org your browser is submitting aGET request. POST is the next most common operation; it is the request sent by your browser when you submit a form. In Rails applications, POST requests are typically used for creating things   
 
4.difference between erb and html, purpose of erb?  
 ERb is the primary template system for including dynamic content in web pages  
5.The asset pipeline(refer http://ruby.railstutorial.org/ chapter-5)  
    Manifest files   
    Preprocessor engines  

6.alternative for javascript,css,html (coffee script,sass,erb)  
 
7.things to follow in ROR  
 (reference 12factor.net)  
 a. MVC  
 b. when to use what (javascript,css,html or coffeescript,sass,erb)  
 c. separation between styles,script and erb.  
 d. time delay between between activerecord and mysql(type of db we use).  
 e.should follow http request method(get,post,patch,delete)  
 
8. x.min.js will make any sense because pre-processor engines default remove unwanted spaces.   
9.Difference between .js and min.js  
 jquery.js = Pretty and easy to read :) Read this one.  
 jquery.min.js = Looks like jibberish! But has a smaller file size. Put this one on your site.  
 Both are the same in functionality. The difference is only in whether it's formatted nicely for readability or compactly for smaller file size.  
 Specifically, the second one is minified, a process which involves removing unnecessary whitespace and shortening variable names. Both contribute to making the code much harder to read: the removal of whitespace removes line breaks and spaces messing up the formatting, and the shortening of variable names (including some function names) replaces the original variable names with meaningless letters.  
 All this is done in such a way that it doesn't affect the way the code behaves when run, in any way. Notably, the replacement/shortening of variable and function names is only done to names that appear in a local scope where it won't interfere with any other code in other scripts.  
10.unobtrusive JS  
 The benefits of unobtrusive JavaScript won’t really appear until our web application has a lot more JavaScript in it as then the advantages of having all of the scripts in a separate file and being able to remove duplication begin to show themselves.  
11. difference between include, load, require, extend   
12. metaprogramming  
13. difference bwtwen render and redirect  
14 about mongo db  
15. sql database modeling   
16. about scrum  
17. custom routes(http://guides.rubyonrails.org/routing.html#naming-routes)  
18. ORM  
19.What Is the Difference Between a Block, a Proc, and a Lambda in Ruby?  
20.http://awaxman11.github.io/blog/2013/08/05/what-is-the-difference-between-a-block/