rails interview questions
1 what is csrf- cross site request forgery and how rails is protected against it ?
csrf is a form of attack where hacker submits a page on your behalf to a different website , causing damage or revealing ur sensitive data , to protect from csrf attacks you have to add protect_from_forgery to your application controller, this will cause rails to require a CSRF token to process the request , csrf token is given as a hidden field in every form created using Rails from builders.
2. what is mixin in rails ?
mixin in ruby offers an alternative to multiple inheritances ,using mixin modules can be imported inside other class
3. how you defines type of varibales in ruby
- Ruby Instance variable begins with — @
- Ruby Class variables begin with — @@
- Ruby Global variables begin with — $
config.frameworks = [ action_web_service, :action_mailer, :active_record] 5. what are sweepers in rails ? sweepers are responsible for expiring or terminating caches when model changes 6. types of varibales in ruby class local, global, class, instance 7. what is object oriented programming language ? features in the object oriented programming language : 1. data encapsulation 2. data abstraction 3. polymorphism 4. inheritance ............................................. ............................................. ............................................. gemfile -gemfile.lock gemfile - where you specify which gem you want to use gemfile.lock - where bundler records the exact version you want to record You write your gem needed for your project in Gemfile i,e Gemfile contain your project gem dependency. But each of these gems may have dependency on one or more other gems, So Gemfile.lock contain complete snapshot of all the gems in Gemfile along with there associated dependency. gemfile - where u specify which gem u want to use and lets you specify which versions gemfile.lock - where bundler recrords the exact versions that were installed. when the same project is loaded on another machine , running bundle install will look at the gemfile.lock and install the exact same versions rather than not using the gemfile and installing the most recent versions. ......................................................... all files of rails project app- focus at this ..comprises models controllers view and everything inside bin- in this aap - start , setup, update ,destroy config- configure app route and database config.ru - rack configration /rackbased services db - current database schema and migrations. gemfile - gemdependencies gemfile.lock-about bundlers lib - extended modules for your app log - application log files package.json - npm dependencies. public - static files & compiled assets readme.md - documentation file storage - active storage test- unit tests ,fixtures and test appratus tmp - temporary files- pid and cache files vendor - third party code place , vendor gems. gitignore - which files can be ignore by git ruby - verson - default ruby version ......................................................... |
Comments
Post a Comment