# พื้นฐาน Rails (Ruby on Rails) > รูปแบบ MVC, การใช้ข้อตกลงแทนการกำหนดค่า, โครงสร้างโปรเจกต์ Rails, environment ต่าง ๆ - 18 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Ruby on Rails](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions.md) ## 1. ในบริบทของ Rails ตัวย่อ MVC หมายถึงอะไร? **คำตอบ** MVC ย่อมาจาก Model-View-Controller ซึ่งเป็นรูปแบบสถาปัตยกรรมที่แยกแอปพลิเคชันออกเป็นสามองค์ประกอบที่เชื่อมโยงกัน Model จัดการข้อมูลและตรรกะทางธุรกิจ View แสดงส่วนติดต่อผู้ใช้ และ Controller ประสานการโต้ตอบระหว่างทั้งสองส่วน การแยกส่วนนี้ช่วยให้การดูแลรักษาและการทดสอบโค้ดง่ายขึ้น ## 2. บทบาทหลักของ Model ในสถาปัตยกรรม MVC ของ Rails คืออะไร? **คำตอบ** ใน Rails, Model แทนข้อมูลของแอปพลิเคชันและห่อหุ้มตรรกะทางธุรกิจไว้ Model จะโต้ตอบกับฐานข้อมูลผ่าน ActiveRecord จัดการการตรวจสอบความถูกต้อง การเชื่อมโยงระหว่างเอนทิตี และ callbacks Model มีหน้าที่รับผิดชอบความถูกต้องของข้อมูลและกฎทางธุรกิจ โดยเป็นอิสระจากส่วนติดต่อผู้ใช้ ## 3. หลักการ 'Convention over Configuration' ใน Rails หมายถึงอะไร? **คำตอบ** Convention over Configuration หมายความว่า Rails จัดเตรียมค่าเริ่มต้นที่สมเหตุสมผลสำหรับเกือบทุกแง่มุมของแอปพลิเคชัน หากนักพัฒนาทำตามข้อตกลงด้านการตั้งชื่อและโครงสร้าง Rails จะกำหนดค่าการเชื่อมโยงระหว่าง models, controllers และ views ให้โดยอัตโนมัติ สิ่งนี้ช่วยลดโค้ด boilerplate และเร่งการพัฒนาให้เร็วขึ้น ## มีอีก 15 คำถาม - ตามแบบแผนของ Rails ไฟล์ controller ถูกจัดเก็บไว้ที่ใด - ไดเรกทอรีใดที่บรรจุเทมเพลตของ view ในแอปพลิเคชัน Rails สมัครฟรี: 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 - [Routing & Controllers](https://sharpskill.dev/th/technologies/ruby-on-rails/interview-questions/routing-controllers.md): 22 คำถาม, 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/rails-fundamentals