Skip to main content

Posts

Showing posts from May, 2015

Ruby on rails Interview questions with answers for experience?

1)What is the difference between include and extend? Ans: i)Include makes the module methods are available instance of the class.     1)Not available at the class level     2)Available at the instance level ii)extend makes module methods are available class itself.     1)Not available at the class level     2)Available at the instance level   here is a big difference between include and extend in Ruby. Let me show you some code to explain it : Exampl1: module Printable   def self.class_method_x     p 'class_method_x'   end   def instance_method_y     p 'instance_method_y'   end end — class ExtendDocument   extend Printable end — class IncludeDocument   include Printable end First round, on the Printable module : Printable.class_method_x # => "class_method_x" — Printable.instance_method_y # => NoMethodError: undefined method `instance_method_y' for Printable...

Implementing has_and_belongs_to_many association in Rails3?

 Implementing has_and_belongs_to_many association in Rails3 ? A has_and_belongs_to_many association directly creates a many-to-many connection between models. This blog will illustrate how to implement such relation in Rails3 using this example - if an application includes two models :- 1. Event 2. Organizer Here each Event can have many Organizers and each Organizer can appear in many Events. Following are the required steps for implementing such relation :- 1. Generate the models using the command rails g model Organizer rails g model Event Note: you can add necessary attributes to the models. 2. Declare the models in this way class Event < ActiveRecord::Base   has_and_belongs_to_many :organizers #append this line to your model end class Organizer < ActiveRecord::Base   has_and_belongs_to_many :events       #append this line to your model end 3. On running rake db:migrate for these models, by default rails create a column id in its t...

Ruby on rails Interview questions for experience?

Ruby on rails Interview questions for experience? 1)What is the difference between include and extend? 2)How to convert the string to integer in jquery? 3)What are the changes in ruby2.2.0? 4)What is the tubolinks? 5)What is the strong parameterized? 6)What are the acess speicifiers in rails? 7)What is the Habtm? 8)How to get the second maxmimun highet age from user table? 9)How to write the class methods? 10)What is the module? 11)Jquery click and bind functions explain? 12)What is the Russian Doll Caching? 13)What is the difference between proc and lamda? 14)What is the scope? 15)What is the caching? 16)What are the associations? 17)what is the mvc? 18)What are variables in rails? 19)How to set the tablename  in rails? 20)What is the difference between ruby hash and parameters hash? 21)How to call the class methods in rails? 22)What is the difference between mysql and postgresql? 23)What is the crontask?What gem used for crontask? 24)How to implement cus...