# Routing & Controllers (Ruby on Rails) > RESTful routes, resources, nested routes, action พื้นฐาน, params, strong parameters - 22 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Ruby on Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions.md) ## 1. ในแอปพลิเคชัน Rails ไฟล์การกำหนดค่า route หลักอยู่ที่ไหน? **คำตอบ** ไฟล์ config/routes.rb คือจุดศูนย์กลางสำหรับการกำหนด route ทั้งหมดในแอปพลิเคชัน Rails ไฟล์นี้จะแมป URL ที่เข้ามาไปยัง controller และ action ที่สอดคล้องกัน Rails จะอ่านไฟล์นี้เมื่อแอปพลิเคชันเริ่มทำงานเพื่อสร้างตาราง routing ที่กำหนดว่าแต่ละ HTTP request จะถูกจัดการอย่างไร ## 2. การประกาศ resources :articles ในไฟล์ routes.rb สร้าง route ขึ้นมากี่ route? **คำตอบ** การประกาศ resources จะสร้าง route แบบ RESTful มาตรฐานขึ้นมา 7 route โดยอัตโนมัติ ได้แก่ index (GET /articles), show (GET /articles/:id), new (GET /articles/new), create (POST /articles), edit (GET /articles/:id/edit), update (PATCH/PUT /articles/:id) และ destroy (DELETE /articles/:id) ข้อตกลงนี้ของ Rails ช่วยลดความซับซ้อนในการกำหนดค่า routing สำหรับการดำเนินการ CRUD มาตรฐานได้อย่างมาก ## 3. HTTP method ใดที่ใช้สำหรับ action create ของ resource แบบ RESTful ใน Rails? **คำตอบ** action create ใช้ HTTP method POST ตามข้อตกลงของ REST โดย POST ใช้สำหรับสร้าง resource ใหม่ เพราะ method นี้ไม่เป็น idempotent (การเรียกหลายครั้งจะสร้าง resource หลายตัว) ฟอร์มที่สร้างโดย action new จะส่งข้อมูลผ่าน POST ไปยัง action create ของ controller ## มีอีก 19 คำถาม - ความแตกต่างระหว่าง resource (เอกพจน์) กับ resources (พหูพจน์) ใน routing ของ Rails คืออะไร? - จะจำกัด route ที่สร้างโดย resources ให้มีเฉพาะ index และ show ได้อย่างไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Ruby on Rails อื่นๆ - [พื้นฐาน Ruby](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/ruby-basics.md): 25 คำถาม, Junior - [การเขียนโปรแกรมเชิงวัตถุใน Ruby](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/ruby-oop.md): 20 คำถาม, Junior - [พื้นฐาน Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-fundamentals.md): 18 คำถาม, Junior - [พื้นฐาน ActiveRecord](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/active-record-basics.md): 25 คำถาม, Junior - [Views และ ERB Templates](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/views-erb-templates.md): 20 คำถาม, Junior - [การเชื่อมโยงของ ActiveRecord](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/active-record-associations.md): 24 คำถาม, Mid-Level - [การสอบถาม ActiveRecord ขั้นสูง](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/active-record-queries.md): 28 คำถาม, Mid-Level - [ฟอร์ม Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-forms.md): 20 คำถาม, Mid-Level - [การยืนยันตัวตนและการอนุญาต](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/authentication-authorization.md): 22 คำถาม, Mid-Level - [Asset Pipeline สมัยใหม่และ frontend](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-asset-pipeline.md): 18 คำถาม, Mid-Level - [โหมด API ของ Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-api-mode.md): 20 คำถาม, Mid-Level - [การทดสอบด้วย RSpec](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-testing-rspec.md): 24 คำถาม, Mid-Level - [ActiveJob & Background Jobs](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/active-job-background-jobs.md): 20 คำถาม, Mid-Level - [ActionCable & WebSockets](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/action-cable-websockets.md): 18 คำถาม, Mid-Level - [ActionMailer](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/action-mailer.md): 18 คำถาม, Mid-Level - [ActiveStorage](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/active-storage.md): 20 คำถาม, Mid-Level - [กลยุทธ์การ Caching](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/caching-strategies.md): 20 คำถาม, Mid-Level - [การ Migration ขั้นสูง](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/database-migrations-advanced.md): 20 คำถาม, Mid-Level - [Rails Engines และแอปแบบโมดูลาร์](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-engines-modular-apps.md): 18 คำถาม, Senior - [การเพิ่มประสิทธิภาพการทำงาน](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/performance-optimization.md): 26 คำถาม, Senior - [Design Patterns ใน Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-design-patterns.md): 22 คำถาม, Senior - [เมตาโปรแกรมมิงใน Ruby](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/ruby-metaprogramming.md): 20 คำถาม, Senior - [ความปลอดภัยของ Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-security.md): 22 คำถาม, Senior - [GraphQL กับ Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/graphql-rails.md): 20 คำถาม, Senior - [การดีพลอยและโปรดักชัน](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-deployment-production.md): 20 คำถาม, Senior - [Monitoring & Logging](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/monitoring-logging.md): 20 คำถาม, Senior - [กลยุทธ์การอัปเกรด Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/rails-upgrade-strategies.md): 18 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/routing-controllers