{"id":87970,"date":"2025-03-25T16:50:59","date_gmt":"2025-03-25T09:50:59","guid":{"rendered":"https:\/\/itviecblog.uptech.vn\/?p=82660"},"modified":"2025-06-17T15:11:47","modified_gmt":"2025-06-17T08:11:47","slug":"cau-hoi-phong-van-ruby-on-rails-2","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/","title":{"rendered":"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#Ruby_on_Rails_la_gi\" >Ruby on Rails l\u00e0 g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#Cau_hoi_phong_van_Ruby_on_Rails_cho_Fresher\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Fresher<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#Cau_hoi_phong_van_Ruby_on_Rails_cho_Junior_va_Middle_Developer\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Junior v\u00e0 Middle Developer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#Cau_hoi_phong_van_Ruby_on_Rails_danh_cho_Senior_Developer\" >C\u00e2u\u00a0h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails d\u00e0nh cho Senior Developer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#Cac_meo_phong_van_va_chuan_bi_cho_Ruby_on_Rails\" >C\u00e1c m\u1eb9o ph\u1ecfng v\u1ea5n v\u00e0 chu\u1ea9n b\u1ecb cho Ruby on Rails<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#Tong_ket_cau_hoi_phong_van_Ruby_on_Rails\" >T\u1ed5ng k\u1ebft c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng b\u1ea1n \u0111ang ng\u1ed3i trong m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n, v\u00e0 nh\u00e0 tuy\u1ec3n d\u1ee5ng h\u1ecfi: &#8220;B\u1ea1n c\u00f3 th\u1ec3 gi\u1ea3i th\u00edch ORM trong Ruby on Rails l\u00e0 g\u00ec kh\u00f4ng?&#8221; B\u1ea1n s\u1ebd tr\u1ea3 l\u1eddi nh\u01b0 th\u1ebf n\u00e0o \u0111\u1ec3 g\u00e2y \u1ea5n t\u01b0\u1ee3ng v\u00e0 th\u1ec3 hi\u1ec7n ki\u1ebfn th\u1ee9c s\u00e2u r\u1ed9ng c\u1ee7a m\u00ecnh? \u0110\u1eebng lo l\u1eafng! B\u00e0i vi\u1ebft n\u00e0y s\u1ebd gi\u00fap b\u1ea1n chu\u1ea9n b\u1ecb cho nh\u1eefng c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao. H\u00e3y c\u00f9ng kh\u00e1m ph\u00e1 v\u00e0 trang b\u1ecb cho m\u00ecnh nh\u1eefng ki\u1ebfn th\u1ee9c c\u1ea7n thi\u1ebft \u0111\u1ec3 t\u1ef1 tin &#8220;chinh ph\u1ee5c&#8221; nh\u00e0 tuy\u1ec3n d\u1ee5ng!<\/strong><\/em><\/p>\n<p>\u0110\u1ecdc b\u00e0i vi\u1ebft sau \u0111\u00e2y \u0111\u1ec3 n\u1eafm v\u1eefng:<\/p>\n<ul>\n<li>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Fresher<\/li>\n<li>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Junior v\u00e0 Middle Developer<\/li>\n<li>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Senior Developer<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Ruby_on_Rails_la_gi\"><\/span><b>Ruby on Rails l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 bi\u1ebft r\u1eb1ng Ruby on Rails \u0111\u00e3 t\u1eebng \u0111\u01b0\u1ee3c v\u00ed nh\u01b0 &#8220;chi\u1ebfc \u0111\u0169a th\u1ea7n&#8221; trong th\u1ebf gi\u1edbi ph\u00e1t tri\u1ec3n web kh\u00f4ng? V\u1edbi kh\u1ea3 n\u0103ng gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean t\u1ea1o ra c\u00e1c \u1ee9ng d\u1ee5ng web m\u1ea1nh m\u1ebd m\u1ed9t c\u00e1ch nhanh ch\u00f3ng, Rails \u0111\u00e3 tr\u1edf th\u00e0nh l\u1ef1a ch\u1ecdn \u01b0u ti\u00ean c\u1ee7a nhi\u1ec1u c\u00f4ng ty c\u00f4ng ngh\u1ec7 h\u00e0ng \u0111\u1ea7u. Ruby on Rails (th\u01b0\u1eddng g\u1ecdi l\u00e0 Rails) l\u00e0 m\u1ed9t framework \u1ee9ng d\u1ee5ng web m\u00e3 ngu\u1ed3n m\u1edf \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh Ruby.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Rails tu\u00e2n theo m\u00f4 h\u00ecnh MVC (Model-View-Controller), gi\u00fap vi\u1ec7c ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng web tr\u1edf n\u00ean d\u1ec5 d\u00e0ng v\u00e0 hi\u1ec7u qu\u1ea3 h\u01a1n. V\u1edbi Rails, l\u1eadp tr\u00ecnh vi\u00ean c\u00f3 th\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng web m\u1ea1nh m\u1ebd v\u1edbi \u00edt m\u00e3 h\u01a1n, nh\u1edd v\u00e0o c\u00e1c quy \u01b0\u1edbc v\u00e0 th\u01b0 vi\u1ec7n s\u1eb5n c\u00f3.<\/span><\/p>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"\/blog\/ruby-on-rails\/\" target=\"_blank\" rel=\"noopener\"><strong>Ruby on Rails l\u00e0 g\u00ec?<\/strong><\/a><\/em><\/p><\/blockquote>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Ruby_on_Rails_cho_Fresher\"><\/span><b>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Fresher<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>Quy \u01b0\u1edbc \u0111\u1eb7t t\u00ean trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Rails tu\u00e2n theo c\u00e1c quy \u01b0\u1edbc \u0111\u1eb7t t\u00ean gi\u00fap t\u1ef1 \u0111\u1ed9ng h\u00f3a nhi\u1ec1u t\u00e1c v\u1ee5:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Model:<\/b><span style=\"font-weight: 400;\"> T\u00ean model \u0111\u01b0\u1ee3c \u0111\u1eb7t \u1edf d\u1ea1ng s\u1ed1 \u00edt v\u00e0 s\u1eed d\u1ee5ng CamelCase (v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">Book<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">UserAccount<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Controller:<\/b><span style=\"font-weight: 400;\"> T\u00ean controller \u1edf d\u1ea1ng s\u1ed1 nhi\u1ec1u v\u00e0 k\u1ebft th\u00fac b\u1eb1ng <\/span><span style=\"font-weight: 400;\">Controller<\/span><span style=\"font-weight: 400;\"> (v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">BooksController<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">UserAccountsController<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Database Table:<\/b><span style=\"font-weight: 400;\"> T\u00ean b\u1ea3ng trong c\u01a1 s\u1edf d\u1eef li\u1ec7u \u1edf d\u1ea1ng s\u1ed1 nhi\u1ec1u v\u00e0 s\u1eed d\u1ee5ng snake_case (v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">books<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">user_accounts<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>File names:<\/b><span style=\"font-weight: 400;\"> T\u00ean file \u0111\u01b0\u1ee3c \u0111\u1eb7t theo snake_case, v\u00ed d\u1ee5 <\/span><span style=\"font-weight: 400;\">book.rb<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">user_account.rb<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<h3><b>Gi\u1ea3i th\u00edch v\u1ec1 ORM trong Ruby on Rails?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">ORM (Object-Relational Mapping) trong Rails \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n th\u00f4ng qua Active Record. N\u00f3 cho ph\u00e9p l\u1eadp tr\u00ecnh vi\u00ean t\u01b0\u01a1ng t\u00e1c v\u1edbi c\u01a1 s\u1edf d\u1eef li\u1ec7u b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng Ruby thay v\u00ec vi\u1ebft c\u00e1c c\u00e2u l\u1ec7nh SQL tr\u1ef1c ti\u1ebfp. \u0110i\u1ec1u n\u00e0y gi\u00fap m\u00e3 ngu\u1ed3n tr\u1edf n\u00ean r\u00f5 r\u00e0ng, d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 gi\u1ea3m thi\u1ec3u l\u1ed7i do vi\u1ec7c vi\u1ebft SQL th\u1ee7 c\u00f4ng.<\/span><\/p>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><b>false<\/b><b> v\u00e0 <\/b><b>nil<\/b><b> trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>false<\/b><b>:<\/b><span style=\"font-weight: 400;\"> L\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb boolean, bi\u1ec3u th\u1ecb cho &#8220;sai&#8221;.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>nil<\/b><b>:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ea1i di\u1ec7n cho &#8220;kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb&#8221; ho\u1eb7c &#8220;kh\u00f4ng t\u1ed3n t\u1ea1i&#8221;.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">C\u1ea3 <\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">nil<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec1u \u0111\u01b0\u1ee3c coi l\u00e0 gi\u00e1 tr\u1ecb &#8220;falsy&#8221; trong Ruby, ngh\u0129a l\u00e0 ch\u00fang s\u1ebd tr\u1ea3 v\u1ec1 <\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\"> trong bi\u1ec3u th\u1ee9c \u0111i\u1ec1u ki\u1ec7n. Tuy nhi\u00ean, ch\u00fang \u0111\u1ea1i di\u1ec7n cho hai kh\u00e1i ni\u1ec7m kh\u00e1c nhau.<\/span><\/p>\n<h3><b>S\u1ef1 kh\u00e1c nhau gi\u1eefa String v\u00e0 Symbol l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>String (<\/b><b>&#8220;hello&#8221;<\/b><b>):<\/b><span style=\"font-weight: 400;\"> L\u00e0 m\u1ed9t chu\u1ed7i k\u00fd t\u1ef1 c\u00f3 th\u1ec3 thay \u0111\u1ed5i \u0111\u01b0\u1ee3c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Symbol (<\/b><b>:hello<\/b><b>):<\/b><span style=\"font-weight: 400;\"> L\u00e0 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng b\u1ea5t bi\u1ebfn, th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng nh\u01b0 kh\u00f3a (key) trong hash ho\u1eb7c \u0111\u1ec3 \u0111\u1ea1i di\u1ec7n cho t\u00ean ph\u01b0\u01a1ng th\u1ee9c.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Symbols ti\u00eau t\u1ed1n \u00edt b\u1ed9 nh\u1edb h\u01a1n v\u00e0 hi\u1ec7u qu\u1ea3 h\u01a1n khi s\u1eed d\u1ee5ng l\u00e0m \u0111\u1ecbnh danh ho\u1eb7c kh\u00f3a.<\/span><\/p>\n<h3><b>Vai tr\u00f2 c\u1ee7a th\u01b0 m\u1ee5c <\/b><b>app\/controllers<\/b><b> v\u00e0 <\/b><b>app\/helpers<\/b><b> l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>app\/controllers<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Ch\u1ee9a c\u00e1c controller, n\u01a1i x\u1eed l\u00fd c\u00e1c y\u00eau c\u1ea7u t\u1eeb ng\u01b0\u1eddi d\u00f9ng, t\u01b0\u01a1ng t\u00e1c v\u1edbi model v\u00e0 ch\u1ecdn view \u0111\u1ec3 hi\u1ec3n th\u1ecb.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>app\/helpers<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Ch\u1ee9a c\u00e1c helper module, cung c\u1ea5p c\u00e1c ph\u01b0\u01a1ng th\u1ee9c h\u1ed7 tr\u1ee3 cho view, gi\u00fap m\u00e3 ngu\u1ed3n tr\u1edf n\u00ean g\u1ecdn g\u00e0ng v\u00e0 t\u00e1i s\u1eed d\u1ee5ng.<\/span><\/li>\n<\/ul>\n<h3><b>Active Record trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Active Record l\u00e0 th\u00e0nh ph\u1ea7n ORM c\u1ee7a Rails, cung c\u1ea5p l\u1edbp giao ti\u1ebfp gi\u1eefa \u1ee9ng d\u1ee5ng v\u00e0 c\u01a1 s\u1edf d\u1eef li\u1ec7u. N\u00f3 gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean thao t\u00e1c v\u1edbi d\u1eef li\u1ec7u b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng Ruby, h\u1ed7 tr\u1ee3 c\u00e1c ch\u1ee9c n\u0103ng nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u1ecbnh ngh\u0129a m\u1ed1i quan h\u1ec7 gi\u1eefa c\u00e1c model.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Th\u1ef1c hi\u1ec7n c\u00e1c thao t\u00e1c CRUD (Create, Read, Update, Delete).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u00e1c th\u1ef1c d\u1eef li\u1ec7u tr\u01b0\u1edbc khi l\u01b0u v\u00e0o c\u01a1 s\u1edf d\u1eef li\u1ec7u.<\/span><\/li>\n<\/ul>\n<h3><b>Rails Migration l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Migration trong Rails l\u00e0 c\u00e1ch qu\u1ea3n l\u00fd c\u00e1c thay \u0111\u1ed5i trong c\u1ea5u tr\u00fac c\u01a1 s\u1edf d\u1eef li\u1ec7u theo th\u1eddi gian. Th\u00f4ng qua migration, l\u1eadp tr\u00ecnh vi\u00ean c\u00f3 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea1o, s\u1eeda \u0111\u1ed5i ho\u1eb7c x\u00f3a b\u1ea3ng v\u00e0 c\u1ed9t.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Qu\u1ea3n l\u00fd phi\u00ean b\u1ea3n c\u1ee7a c\u01a1 s\u1edf d\u1eef li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Chia s\u1ebb v\u00e0 \u0111\u1ed3ng b\u1ed9 h\u00f3a c\u1ea5u tr\u00fac c\u01a1 s\u1edf d\u1eef li\u1ec7u gi\u1eefa c\u00e1c th\u00e0nh vi\u00ean trong nh\u00f3m.<\/span><\/li>\n<\/ul>\n<h3><b>C\u00e1c ch\u1ee9c n\u0103ng c\u1ee7a Rails Migration?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u1ea1o b\u1ea3ng m\u1edbi:<\/b> <span style=\"font-weight: 400;\">create_table<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Th\u00eam c\u1ed9t m\u1edbi:<\/b> <span style=\"font-weight: 400;\">add_column<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>\u0110\u1ed5i t\u00ean c\u1ed9t ho\u1eb7c b\u1ea3ng:<\/b> <span style=\"font-weight: 400;\">rename_column<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">rename_table<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>X\u00f3a c\u1ed9t ho\u1eb7c b\u1ea3ng:<\/b> <span style=\"font-weight: 400;\">remove_column<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">drop_table<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Th\u00eam ch\u1ec9 m\u1ee5c:<\/b> <span style=\"font-weight: 400;\">add_index<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<h3><b>Mixin trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Mixin trong Ruby l\u00e0 c\u00e1ch th\u00eam c\u00e1c ph\u01b0\u01a1ng th\u1ee9c v\u00e0o m\u1ed9t l\u1edbp th\u00f4ng qua module. B\u1eb1ng c\u00e1ch <\/span><span style=\"font-weight: 400;\">include<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">extend<\/span><span style=\"font-weight: 400;\"> module, l\u1edbp c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a trong module \u0111\u00f3. Mixin gi\u00fap:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u00e1i s\u1eed d\u1ee5ng m\u00e3 ngu\u1ed3n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Tr\u00e1nh vi\u1ec7c \u0111a k\u1ebf th\u1eeba ph\u1ee9c t\u1ea1p.<\/span><\/li>\n<\/ul>\n<h3><b> C\u00e1ch \u0111\u1ecbnh ngh\u0129a c\u00e1c lo\u1ea1i bi\u1ebfn trong Ruby (Instance, Global, v\u00e0 Class)?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Bi\u1ebfn Instance:<\/b><span style=\"font-weight: 400;\"> B\u1eaft \u0111\u1ea7u b\u1eb1ng <\/span><span style=\"font-weight: 400;\">@<\/span><span style=\"font-weight: 400;\">, thu\u1ed9c v\u1ec1 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng c\u1ee5 th\u1ec3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Bi\u1ebfn Class:<\/b><span style=\"font-weight: 400;\"> B\u1eaft \u0111\u1ea7u b\u1eb1ng <\/span><span style=\"font-weight: 400;\">@@<\/span><span style=\"font-weight: 400;\">, \u0111\u01b0\u1ee3c chia s\u1ebb gi\u1eefa t\u1ea5t c\u1ea3 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng c\u1ee7a l\u1edbp.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Bi\u1ebfn Global:<\/b><span style=\"font-weight: 400;\"> B\u1eaft \u0111\u1ea7u b\u1eb1ng <\/span><span style=\"font-weight: 400;\">$<\/span><span style=\"font-weight: 400;\">, c\u00f3 ph\u1ea1m vi to\u00e0n c\u1ee5c v\u00e0 c\u00f3 th\u1ec3 truy c\u1eadp t\u1eeb b\u1ea5t k\u1ef3 n\u01a1i n\u00e0o.<\/span><\/li>\n<\/ul>\n<h3><b> C\u00f3 bao nhi\u00eau lo\u1ea1i quan h\u1ec7 li\u00ean k\u1ebft trong m\u1ed9t Model?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong Rails, c\u00f3 c\u00e1c lo\u1ea1i quan h\u1ec7 li\u00ean k\u1ebft ch\u00ednh trong model:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">belongs_to<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">has_one<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">has_many<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">has_many :through<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">has_one :through<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">has_and_belongs_to_many<\/span><\/li>\n<\/ul>\n<h3><b>Gi\u00e0n gi\u00e1o (Scaffolding) trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Scaffolding trong Rails l\u00e0 m\u1ed9t t\u00ednh n\u0103ng cho ph\u00e9p t\u1ef1 \u0111\u1ed9ng t\u1ea1o ra m\u00e3 ngu\u1ed3n cho c\u00e1c thao t\u00e1c CRUD c\u01a1 b\u1ea3n (Create, Read, Update, Delete) d\u1ef1a tr\u00ean c\u1ea5u tr\u00fac model. N\u00f3 t\u1ea1o ra controller, view, v\u00e0 route c\u1ea7n thi\u1ebft \u0111\u1ec3 qu\u1ea3n l\u00fd d\u1eef li\u1ec7u m\u1ed9t c\u00e1ch nhanh ch\u00f3ng.<\/span><\/p>\n<h3><b> Ba m\u00f4i tr\u01b0\u1eddng m\u1eb7c \u0111\u1ecbnh trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Ba m\u00f4i tr\u01b0\u1eddng m\u1eb7c \u0111\u1ecbnh trong Rails l\u00e0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">development<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">test<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">production<\/span><\/li>\n<\/ul>\n<h3><b> Ba th\u00e0nh ph\u1ea7n c\u1ee7a Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Ba th\u00e0nh ph\u1ea7n ch\u00ednh c\u1ee7a Rails l\u00e0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Active Record:<\/b><span style=\"font-weight: 400;\"> ORM \u0111\u1ec3 t\u01b0\u01a1ng t\u00e1c v\u1edbi c\u01a1 s\u1edf d\u1eef li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Action Controller:<\/b><span style=\"font-weight: 400;\"> X\u1eed l\u00fd y\u00eau c\u1ea7u HTTP v\u00e0 ph\u1ea3n h\u1ed3i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Action View:<\/b><span style=\"font-weight: 400;\"> T\u1ea1o ra giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Ruby_on_Rails_cho_Junior_va_Middle_Developer\"><\/span><b>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails cho Junior v\u00e0 Middle Developer<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">B\u1ea1n \u0111\u00e3 n\u1eafm v\u1eefng nh\u1eefng ki\u1ebfn th\u1ee9c c\u01a1 b\u1ea3n v\u1ec1 Ruby on Rails v\u00e0 mu\u1ed1n &#8220;n\u00e2ng c\u1ea5p&#8221; b\u1ea3n th\u00e2n? H\u00e3y c\u00f9ng kh\u00e1m ph\u00e1 nh\u1eefng c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n d\u00e0nh cho ng\u01b0\u1eddi c\u00f3 kinh nghi\u1ec7m, gi\u00fap b\u1ea1n th\u1ec3 hi\u1ec7n s\u1ef1 hi\u1ec3u bi\u1ebft s\u00e2u r\u1ed9ng v\u00e0 kh\u1ea3 n\u0103ng \u1ee9ng d\u1ee5ng th\u1ef1c t\u1ebf c\u1ee7a m\u00ecnh.<\/span><\/p>\n<h3><b>Gemfile trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Gemfile<\/b><span style=\"font-weight: 400;\"> l\u00e0 t\u1ec7p tin quan tr\u1ecdng trong m\u1ed7i d\u1ef1 \u00e1n Rails, n\u01a1i b\u1ea1n khai b\u00e1o t\u1ea5t c\u1ea3 c\u00e1c <\/span><b>gem<\/b><span style=\"font-weight: 400;\"> (th\u01b0 vi\u1ec7n Ruby) m\u00e0 \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n ph\u1ee5 thu\u1ed9c. B\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng Gemfile, b\u1ea1n c\u00f3 th\u1ec3 qu\u1ea3n l\u00fd c\u00e1c gem m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng, \u0111\u1ea3m b\u1ea3o m\u1ecdi th\u00e0nh vi\u00ean trong nh\u00f3m ph\u00e1t tri\u1ec3n \u0111\u1ec1u s\u1eed d\u1ee5ng c\u00f9ng m\u1ed9t phi\u00ean b\u1ea3n gem, gi\u00fap d\u1ef1 \u00e1n ho\u1ea1t \u0111\u1ed9ng \u1ed5n \u0111\u1ecbnh v\u00e0 tr\u00e1nh xung \u0111\u1ed9t phi\u00ean b\u1ea3n.<\/span><\/p>\n<h3><b>MVC l\u00e0 g\u00ec v\u00e0 n\u00f3 ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><b>MVC<\/b><span style=\"font-weight: 400;\"> (Model-View-Controller) l\u00e0 m\u00f4 h\u00ecnh ki\u1ebfn tr\u00fac ph\u1ea7n m\u1ec1m ph\u00e2n t\u00e1ch \u1ee9ng d\u1ee5ng th\u00e0nh ba th\u00e0nh ph\u1ea7n ch\u00ednh:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Model:<\/b><span style=\"font-weight: 400;\"> Qu\u1ea3n l\u00fd d\u1eef li\u1ec7u v\u00e0 logic nghi\u1ec7p v\u1ee5. \u0110\u00e2y l\u00e0 n\u01a1i b\u1ea1n \u0111\u1ecbnh ngh\u0129a c\u00e1c l\u1edbp, x\u00e1c th\u1ef1c d\u1eef li\u1ec7u v\u00e0 t\u01b0\u01a1ng t\u00e1c v\u1edbi c\u01a1 s\u1edf d\u1eef li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>View:<\/b><span style=\"font-weight: 400;\"> Ch\u1ecbu tr\u00e1ch nhi\u1ec7m hi\u1ec3n th\u1ecb d\u1eef li\u1ec7u cho ng\u01b0\u1eddi d\u00f9ng. View th\u01b0\u1eddng l\u00e0 c\u00e1c t\u1ec7p HTML \u0111\u01b0\u1ee3c k\u1ebft h\u1ee3p v\u1edbi m\u00e3 Ruby \u0111\u1ec3 t\u1ea1o ra n\u1ed9i dung \u0111\u1ed9ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Controller:<\/b><span style=\"font-weight: 400;\"> X\u1eed l\u00fd c\u00e1c y\u00eau c\u1ea7u t\u1eeb ng\u01b0\u1eddi d\u00f9ng, t\u01b0\u01a1ng t\u00e1c v\u1edbi Model v\u00e0 ch\u1ecdn View ph\u00f9 h\u1ee3p \u0111\u1ec3 hi\u1ec3n th\u1ecb.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Trong Rails, khi ng\u01b0\u1eddi d\u00f9ng g\u1eedi m\u1ed9t y\u00eau c\u1ea7u, Router s\u1ebd chuy\u1ec3n ti\u1ebfp y\u00eau c\u1ea7u \u0111\u00f3 t\u1edbi Controller th\u00edch h\u1ee3p. Controller s\u1ebd s\u1eed d\u1ee5ng Model \u0111\u1ec3 l\u1ea5y ho\u1eb7c c\u1eadp nh\u1eadt d\u1eef li\u1ec7u, sau \u0111\u00f3 ch\u1ecdn View \u0111\u1ec3 hi\u1ec3n th\u1ecb k\u1ebft qu\u1ea3 cho ng\u01b0\u1eddi d\u00f9ng.<\/span><\/p>\n<h3><b>Garbage Collection trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Garbage Collection (GC)<\/b><span style=\"font-weight: 400;\"> l\u00e0 c\u01a1 ch\u1ebf t\u1ef1 \u0111\u1ed9ng qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb trong Ruby. GC gi\u00fap gi\u1ea3i ph\u00f3ng b\u1ed9 nh\u1edb c\u1ee7a c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00f4ng c\u00f2n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng, ng\u0103n ch\u1eb7n r\u00f2 r\u1ec9 b\u1ed9 nh\u1edb v\u00e0 c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t c\u1ee7a \u1ee9ng d\u1ee5ng. Trong Rails, GC \u0111\u1ea3m b\u1ea3o r\u1eb1ng \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n kh\u00f4ng ti\u00eau t\u1ed1n qu\u00e1 nhi\u1ec1u b\u1ed9 nh\u1edb v\u00e0 ho\u1ea1t \u0111\u1ed9ng m\u01b0\u1ee3t m\u00e0 h\u01a1n.<\/span><\/p>\n<h3><b>Ruby Class Library l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Ruby Class Library<\/b><span style=\"font-weight: 400;\"> l\u00e0 t\u1eadp h\u1ee3p c\u00e1c l\u1edbp v\u00e0 module \u0111\u01b0\u1ee3c t\u00edch h\u1ee3p s\u1eb5n trong ng\u00f4n ng\u1eef Ruby. Ch\u00fang cung c\u1ea5p c\u00e1c ch\u1ee9c n\u0103ng c\u01a1 b\u1ea3n nh\u01b0 x\u1eed l\u00fd chu\u1ed7i, s\u1ed1, m\u1ea3ng, hash, c\u0169ng nh\u01b0 c\u00e1c t\u00e1c v\u1ee5 ph\u1ee9c t\u1ea1p h\u01a1n nh\u01b0 l\u1eadp tr\u00ecnh m\u1ea1ng, x\u1eed l\u00fd file v\u00e0 lu\u1ed3ng. Vi\u1ec7c s\u1eed d\u1ee5ng c\u00e1c th\u01b0 vi\u1ec7n n\u00e0y gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean ti\u1ebft ki\u1ec7m th\u1eddi gian v\u00e0 c\u00f4ng s\u1ee9c, t\u1eadp trung v\u00e0o ph\u00e1t tri\u1ec3n logic nghi\u1ec7p v\u1ee5 thay v\u00ec x\u00e2y d\u1ef1ng l\u1ea1i c\u00e1c ch\u1ee9c n\u0103ng c\u01a1 b\u1ea3n.<\/span><\/p>\n<h3><b>DRY (Don&#8217;t Repeat Yourself) code l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>DRY<\/b><span style=\"font-weight: 400;\"> l\u00e0 nguy\u00ean t\u1eafc l\u1eadp tr\u00ecnh khuy\u1ebfn kh\u00edch vi\u1ec7c tr\u00e1nh l\u1eb7p l\u1ea1i m\u00e3 ngu\u1ed3n. Thay v\u00ec vi\u1ebft c\u00f9ng m\u1ed9t \u0111o\u1ea1n m\u00e3 \u1edf nhi\u1ec1u n\u01a1i, b\u1ea1n n\u00ean tr\u1eebu t\u01b0\u1ee3ng h\u00f3a v\u00e0 t\u00e1i s\u1eed d\u1ee5ng m\u00e3 th\u00f4ng qua c\u00e1c ph\u01b0\u01a1ng th\u1ee9c, l\u1edbp ho\u1eb7c module. \u0110i\u1ec1u n\u00e0y gi\u00fap:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Gi\u1ea3m thi\u1ec3u l\u1ed7i:<\/b><span style=\"font-weight: 400;\"> \u00cdt m\u00e3 h\u01a1n \u0111\u1ed3ng ngh\u0129a v\u1edbi \u00edt ch\u1ed7 cho l\u1ed7i x\u1ea3y ra.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>D\u1ec5 b\u1ea3o tr\u00ec:<\/b><span style=\"font-weight: 400;\"> Khi c\u1ea7n thay \u0111\u1ed5i, b\u1ea1n ch\u1ec9 c\u1ea7n c\u1eadp nh\u1eadt m\u1ed9t n\u01a1i duy nh\u1ea5t.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>M\u00e3 ngu\u1ed3n s\u1ea1ch s\u1ebd:<\/b><span style=\"font-weight: 400;\"> Gi\u00fap m\u00e3 d\u1ec5 \u0111\u1ecdc v\u00e0 d\u1ec5 hi\u1ec3u h\u01a1n.<\/span><\/li>\n<\/ul>\n<h3><b>L\u1ee3i \u00edch c\u1ee7a vi\u1ec7c s\u1eed d\u1ee5ng Ruby on Rails?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Ruby on Rails mang l\u1ea1i nhi\u1ec1u l\u1ee3i \u00edch cho l\u1eadp tr\u00ecnh vi\u00ean v\u00e0 doanh nghi\u1ec7p:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ph\u00e1t tri\u1ec3n nhanh ch\u00f3ng:<\/b><span style=\"font-weight: 400;\"> V\u1edbi nhi\u1ec1u c\u00f4ng c\u1ee5 v\u00e0 th\u01b0 vi\u1ec7n s\u1eb5n c\u00f3, b\u1ea1n c\u00f3 th\u1ec3 x\u00e2y d\u1ef1ng \u1ee9ng d\u1ee5ng m\u1ed9t c\u00e1ch nhanh ch\u00f3ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>C\u1ed9ng \u0111\u1ed3ng l\u1edbn:<\/b><span style=\"font-weight: 400;\"> Rails c\u00f3 m\u1ed9t c\u1ed9ng \u0111\u1ed3ng n\u0103ng \u0111\u1ed9ng, cung c\u1ea5p nhi\u1ec1u t\u00e0i li\u1ec7u, gem v\u00e0 h\u1ed7 tr\u1ee3 khi b\u1ea1n g\u1eb7p v\u1ea5n \u0111\u1ec1.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Nguy\u00ean t\u1eafc &#8220;Convention over Configuration&#8221;:<\/b><span style=\"font-weight: 400;\"> Gi\u1ea3m thi\u1ec3u vi\u1ec7c c\u1ea5u h\u00ecnh, gi\u00fap b\u1ea1n t\u1eadp trung v\u00e0o logic nghi\u1ec7p v\u1ee5.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>B\u1ea3o m\u1eadt t\u00edch h\u1ee3p:<\/b><span style=\"font-weight: 400;\"> Rails t\u00edch h\u1ee3p nhi\u1ec1u bi\u1ec7n ph\u00e1p b\u1ea3o m\u1eadt m\u1eb7c \u0111\u1ecbnh, gi\u00fap b\u1ea3o v\u1ec7 \u1ee9ng d\u1ee5ng kh\u1ecfi c\u00e1c l\u1ed7 h\u1ed5ng ph\u1ed5 bi\u1ebfn.<\/span><\/li>\n<\/ul>\n<h3><b>Nested Layout trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Nested Layout<\/b><span style=\"font-weight: 400;\"> cho ph\u00e9p b\u1ea1n s\u1eed d\u1ee5ng m\u1ed9t layout b\u00ean trong m\u1ed9t layout kh\u00e1c. \u0110i\u1ec1u n\u00e0y h\u1eefu \u00edch khi b\u1ea1n c\u00f3 nhi\u1ec1u ph\u1ea7n c\u1ee7a \u1ee9ng d\u1ee5ng chia s\u1ebb chung m\u1ed9t giao di\u1ec7n, nh\u01b0ng c\u0169ng c\u00f3 nh\u1eefng ph\u1ea7n ri\u00eang bi\u1ec7t. B\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng nested layout, b\u1ea1n c\u00f3 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00e1i s\u1eed d\u1ee5ng giao di\u1ec7n:<\/b><span style=\"font-weight: 400;\"> Gi\u1ea3m thi\u1ec3u vi\u1ec7c l\u1eb7p l\u1ea1i m\u00e3 HTML.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u1ed5 ch\u1ee9c c\u1ea5u tr\u00fac giao di\u1ec7n r\u00f5 r\u00e0ng h\u01a1n.<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>D\u1ec5 d\u00e0ng thay \u0111\u1ed5i giao di\u1ec7n t\u1ed5ng th\u1ec3 m\u00e0 kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn c\u00e1c ph\u1ea7n t\u1eed con.<\/b><\/li>\n<\/ul>\n<h3><b>Vai tr\u00f2 c\u1ee7a <\/b><b>load<\/b><b> v\u00e0 <\/b><b>require<\/b><b> trong Ruby?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>require<\/b><b>:<\/b><span style=\"font-weight: 400;\"> D\u00f9ng \u0111\u1ec3 n\u1ea1p m\u1ed9t th\u01b0 vi\u1ec7n ho\u1eb7c t\u1ec7p tin ch\u1ec9 m\u1ed9t l\u1ea7n duy nh\u1ea5t. N\u1ebfu b\u1ea1n g\u1ecdi <\/span><span style=\"font-weight: 400;\">require<\/span><span style=\"font-weight: 400;\"> nhi\u1ec1u l\u1ea7n cho c\u00f9ng m\u1ed9t t\u1ec7p, Ruby s\u1ebd ch\u1ec9 n\u1ea1p n\u00f3 m\u1ed9t l\u1ea7n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>load<\/b><b>:<\/b><span style=\"font-weight: 400;\"> D\u00f9ng \u0111\u1ec3 n\u1ea1p v\u00e0 th\u1ef1c thi m\u1ed9t t\u1ec7p tin m\u1ed7i khi n\u00f3 \u0111\u01b0\u1ee3c g\u1ecdi. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 n\u1ebfu b\u1ea1n thay \u0111\u1ed5i t\u1ec7p tin v\u00e0 g\u1ecdi <\/span><span style=\"font-weight: 400;\">load<\/span><span style=\"font-weight: 400;\"> l\u1ea1i, c\u00e1c thay \u0111\u1ed5i s\u1ebd \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng.<\/span><\/li>\n<\/ul>\n<h3><b>L\u1ec7nh <\/b><b>delete<\/b><b> trong Ruby on Rails ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">delete<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 x\u00f3a m\u1ed9t b\u1ea3n ghi kh\u1ecfi c\u01a1 s\u1edf d\u1eef li\u1ec7u m\u00e0 kh\u00f4ng k\u00edch ho\u1ea1t c\u00e1c callback ho\u1eb7c x\u00e1c th\u1ef1c:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\"># X\u00f3a b\u1ea3n ghi m\u00e0 kh\u00f4ng k\u00edch ho\u1ea1t callback<\/span>\n<span style=\"font-weight: 400;\">@user.delete<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Ng\u01b0\u1ee3c l\u1ea1i, l\u1ec7nh <\/span><span style=\"font-weight: 400;\">destroy<\/span><span style=\"font-weight: 400;\"> s\u1ebd x\u00f3a b\u1ea3n ghi v\u00e0 k\u00edch ho\u1ea1t c\u00e1c callback li\u00ean quan:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\"># X\u00f3a b\u1ea3n ghi v\u00e0 k\u00edch ho\u1ea1t callback<\/span>\n<span style=\"font-weight: 400;\">@user.destroy<\/span><\/pre>\n<h3><b>C\u00e1ch t\u1ea1o comment trong code Ruby?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 t\u1ea1o comment trong Ruby, b\u1ea1n s\u1eed d\u1ee5ng d\u1ea5u th\u0103ng <\/span><span style=\"font-weight: 400;\">#<\/span><span style=\"font-weight: 400;\"> cho comment m\u1ed9t d\u00f2ng. Trong th\u1ef1c t\u1ebf, n\u00ean s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">#<\/span><span style=\"font-weight: 400;\"> cho m\u1ed7i d\u00f2ng comment \u0111\u1ec3 t\u0103ng t\u00ednh nh\u1ea5t qu\u00e1n.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\"># \u0110\u00e2y l\u00e0 m\u1ed9t comment trong Ruby<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Ho\u1eb7c s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">=begin<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">=end<\/span><span style=\"font-weight: 400;\"> cho comment nhi\u1ec1u d\u00f2ng:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">=begin<\/span>\n<span style=\"font-weight: 400;\">\u0110\u00e2y l\u00e0 m\u1ed9t<\/span>\n<span style=\"font-weight: 400;\">comment nhi\u1ec1u d\u00f2ng<\/span>\n<span style=\"font-weight: 400;\">trong Ruby<\/span>\n<span style=\"font-weight: 400;\">=end<\/span><\/pre>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa d\u1ea5u nh\u00e1y \u0111\u01a1n v\u00e0 d\u1ea5u nh\u00e1y k\u00e9p trong chu\u1ed7i l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>D\u1ea5u nh\u00e1y \u0111\u01a1n <\/b><b>&#8216;&#8230;&#8217;<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Chu\u1ed7i \u0111\u01b0\u1ee3c t\u1ea1o ra s\u1ebd gi\u1eef nguy\u00ean n\u1ed9i dung b\u00ean trong, kh\u00f4ng x\u1eed l\u00fd c\u00e1c k\u00fd t\u1ef1 \u0111\u1eb7c bi\u1ec7t ho\u1eb7c bi\u1ebfn.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>D\u1ea5u nh\u00e1y k\u00e9p <\/b><b>&#8220;&#8230;&#8221;<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Ruby s\u1ebd x\u1eed l\u00fd chu\u1ed7i, bao g\u1ed3m vi\u1ec7c thay th\u1ebf bi\u1ebfn v\u00e0 c\u00e1c k\u00fd t\u1ef1 \u0111\u1eb7c bi\u1ec7t nh\u01b0 <\/span><span style=\"font-weight: 400;\">\\n<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">\\t<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">name = <\/span><span style=\"font-weight: 400;\">'Ruby'<\/span>\n<span style=\"font-weight: 400;\">puts <\/span><span style=\"font-weight: 400;\">'Hello, <\/span><span style=\"font-weight: 400;\">#{name}<\/span><span style=\"font-weight: 400;\">'<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\"># Output: Hello, #{name}<\/span>\n<span style=\"font-weight: 400;\">puts <\/span><span style=\"font-weight: 400;\">\"Hello, <\/span><span style=\"font-weight: 400;\">#{name}<\/span><span style=\"font-weight: 400;\">\"<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\"># Output: Hello, Ruby<\/span><\/pre>\n<h3><b>Gems v\u00e0 Gemset trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Gems:<\/b><span style=\"font-weight: 400;\"> L\u00e0 c\u00e1c th\u01b0 vi\u1ec7n ho\u1eb7c ph\u1ea7n m\u1edf r\u1ed9ng \u0111\u01b0\u1ee3c \u0111\u00f3ng g\u00f3i, gi\u00fap b\u1ed5 sung ch\u1ee9c n\u0103ng cho \u1ee9ng d\u1ee5ng Ruby c\u1ee7a b\u1ea1n. B\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t gem th\u00f4ng qua <\/span><span style=\"font-weight: 400;\">gem install<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c khai b\u00e1o trong <\/span><span style=\"font-weight: 400;\">Gemfile<\/span><span style=\"font-weight: 400;\"> v\u00e0 s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">bundle install<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Gemset:<\/b><span style=\"font-weight: 400;\"> L\u00e0 m\u1ed9t t\u00ednh n\u0103ng c\u1ee7a RVM (Ruby Version Manager) ho\u1eb7c rbenv v\u1edbi plugin, cho ph\u00e9p t\u1ea1o c\u00e1c t\u1eadp h\u1ee3p gem ri\u00eang bi\u1ec7t cho t\u1eebng d\u1ef1 \u00e1n, gi\u00fap qu\u1ea3n l\u00fd gem d\u1ec5 d\u00e0ng h\u01a1n.<\/span><\/li>\n<\/ul>\n<h3><b>C\u00e1c lo\u1ea1i Filters trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Filters trong Rails \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong Controller \u0111\u1ec3 th\u1ef1c thi m\u00e3 tr\u01b0\u1edbc ho\u1eb7c sau m\u1ed9t action c\u1ee5 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>before_action<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Th\u1ef1c thi tr\u01b0\u1edbc khi action \u0111\u01b0\u1ee3c g\u1ecdi.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>after_action<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Th\u1ef1c thi sau khi action ho\u00e0n th\u00e0nh.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>around_action<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Bao quanh action, cho ph\u00e9p th\u1ef1c thi m\u00e3 tr\u01b0\u1edbc v\u00e0 sau action.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> ApplicationController &lt; ActionController::Base<\/span>\n<span style=\"font-weight: 400;\">\u00a0 before_action <\/span><span style=\"font-weight: 400;\">:authenticate_user<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h3><b>Helpers trong Ruby on Rails v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng ch\u00fang nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><b>Helpers<\/b><span style=\"font-weight: 400;\"> l\u00e0 c\u00e1c module ch\u1ee9a c\u00e1c ph\u01b0\u01a1ng th\u1ee9c h\u1ed7 tr\u1ee3 cho View, gi\u00fap b\u1ea1n t\u00e1i s\u1eed d\u1ee5ng m\u00e3 v\u00e0 gi\u1eef cho View s\u1ea1ch s\u1ebd. B\u1ea1n c\u00f3 th\u1ec3 \u0111\u1ecbnh ngh\u0129a helpers trong <\/span><span style=\"font-weight: 400;\">app\/helpers<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c tr\u1ef1c ti\u1ebfp trong Controller.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, t\u1ea1o m\u1ed9t helper \u0111\u1ec3 \u0111\u1ecbnh d\u1ea1ng ng\u00e0y:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">module<\/span><span style=\"font-weight: 400;\"> ApplicationHelper<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> format_date<\/span><span style=\"font-weight: 400;\">(date)<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 date.strftime(<\/span><span style=\"font-weight: 400;\">\"%d\/%m\/%Y\"<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong View, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">&lt;p&gt;Ng\u00e0y t\u1ea1<\/span><span style=\"font-weight: 400;\">o:<\/span><span style=\"font-weight: 400;\"> &lt;%= format_date(@post.created_at) %&gt;&lt;<\/span><span style=\"font-weight: 400;\">\/p&gt;<\/span><\/pre>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><b>render<\/b><b> v\u00e0 <\/b><b>redirect_to<\/b><b> l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>render<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Hi\u1ec3n th\u1ecb m\u1ed9t view m\u00e0 kh\u00f4ng thay \u0111\u1ed5i URL tr\u00ean tr\u00ecnh duy\u1ec7t. Th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng khi b\u1ea1n mu\u1ed1n hi\u1ec3n th\u1ecb l\u1ea1i form v\u1edbi th\u00f4ng b\u00e1o l\u1ed7i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>redirect_to<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Chuy\u1ec3n h\u01b0\u1edbng ng\u01b0\u1eddi d\u00f9ng t\u1edbi m\u1ed9t URL kh\u00e1c, y\u00eau c\u1ea7u tr\u00ecnh duy\u1ec7t th\u1ef1c hi\u1ec7n m\u1ed9t y\u00eau c\u1ea7u HTTP m\u1edbi. Th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng sau khi t\u1ea1o ho\u1eb7c c\u1eadp nh\u1eadt th\u00e0nh c\u00f4ng m\u1ed9t b\u1ea3n ghi.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> create<\/span>\n<span style=\"font-weight: 400;\">\u00a0 @post = Post.new(post_params)<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">if<\/span><span style=\"font-weight: 400;\"> @post.save<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 redirect_to @post<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">else<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 render <\/span><span style=\"font-weight: 400;\">:new<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Ruby_on_Rails_danh_cho_Senior_Developer\"><\/span><b>C\u00e2u\u00a0h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails d\u00e0nh cho Senior Developer<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u1ed1i v\u1edbi nh\u1eefng l\u1eadp tr\u00ecnh vi\u00ean c\u00f3 kinh nghi\u1ec7m, vi\u1ec7c hi\u1ec3u s\u00e2u v\u00e0 \u00e1p d\u1ee5ng nh\u1eefng t\u00ednh n\u0103ng n\u00e2ng cao c\u1ee7a Rails l\u00e0 \u0111i\u1ec1u c\u1ea7n thi\u1ebft. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 nh\u1eefng c\u00e2u h\u1ecfi gi\u00fap b\u1ea1n th\u1ec3 hi\u1ec7n ki\u1ebfn th\u1ee9c chuy\u00ean s\u00e2u c\u1ee7a m\u00ecnh.<\/span><\/p>\n<h3><b>Active Job trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Active Job<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t framework t\u00edch h\u1ee3p trong Rails \u0111\u1ec3 khai b\u00e1o, qu\u1ea3n l\u00fd v\u00e0 th\u1ef1c thi c\u00e1c t\u00e1c v\u1ee5 ch\u1ea1y n\u1ec1n (background jobs). N\u00f3 cung c\u1ea5p giao di\u1ec7n th\u1ed1ng nh\u1ea5t cho c\u00e1c backend x\u1eed l\u00fd h\u00e0ng \u0111\u1ee3i nh\u01b0 Sidekiq, Resque, Delayed Job. B\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng Active Job, b\u1ea1n c\u00f3 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">G\u1eedi email.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u1eed l\u00fd c\u00e1c t\u00e1c v\u1ee5 n\u1eb7ng m\u00e0 kh\u00f4ng l\u00e0m gi\u00e1n \u0111o\u1ea1n tr\u1ea3i nghi\u1ec7m ng\u01b0\u1eddi d\u00f9ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">L\u1eadp l\u1ecbch c\u00e1c t\u00e1c v\u1ee5 \u0111\u1ecbnh k\u1ef3.<\/span><\/li>\n<\/ul>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><b>after_save<\/b><b> v\u00e0 <\/b><b>after_commit<\/b><b> l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>after_save<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Callback \u0111\u01b0\u1ee3c g\u1ecdi sau khi m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u01b0\u1ee3c l\u01b0u (c\u1ea3 khi t\u1ea1o m\u1edbi v\u00e0 c\u1eadp nh\u1eadt), nh\u01b0ng tr\u01b0\u1edbc khi giao d\u1ecbch \u0111\u01b0\u1ee3c cam k\u1ebft v\u00e0o c\u01a1 s\u1edf d\u1eef li\u1ec7u. <\/span><span style=\"font-weight: 400;\">after_save<\/span><span style=\"font-weight: 400;\"> c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi nhi\u1ec1u l\u1ea7n n\u1ebfu c\u00f3 nhi\u1ec1u thao t\u00e1c save trong c\u00f9ng m\u1ed9t giao d\u1ecbch.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>after_commit<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Callback \u0111\u01b0\u1ee3c g\u1ecdi sau khi giao d\u1ecbch \u0111\u00e3 \u0111\u01b0\u1ee3c cam k\u1ebft th\u00e0nh c\u00f4ng v\u00e0o c\u01a1 s\u1edf d\u1eef li\u1ec7u. \u0110i\u1ec1u n\u00e0y \u0111\u1ea3m b\u1ea3o r\u1eb1ng d\u1eef li\u1ec7u \u0111\u00e3 th\u1ef1c s\u1ef1 \u0111\u01b0\u1ee3c l\u01b0u v\u00e0 ph\u00f9 h\u1ee3p cho c\u00e1c t\u00e1c v\u1ee5 nh\u01b0 g\u1eedi email ho\u1eb7c c\u1eadp nh\u1eadt c\u00e1c h\u1ec7 th\u1ed1ng b\u00ean ngo\u00e0i. <\/span><span style=\"font-weight: 400;\">after_commit<\/span><span style=\"font-weight: 400;\"> ch\u1ec9 \u0111\u01b0\u1ee3c g\u1ecdi m\u1ed9t l\u1ea7n sau khi giao d\u1ecbch ho\u00e0n t\u1ea5t th\u00e0nh c\u00f4ng.<\/span><\/li>\n<\/ul>\n<h3><b>Asset Pipeline trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Asset Pipeline<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t framework trong Rails gi\u00fap qu\u1ea3n l\u00fd v\u00e0 n\u00e9n c\u00e1c t\u00e0i nguy\u00ean t\u0129nh nh\u01b0 CSS, JavaScript v\u00e0 h\u00ecnh \u1ea3nh. N\u00f3 cung c\u1ea5p:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ti\u1ec1n x\u1eed l\u00fd:<\/b><span style=\"font-weight: 400;\"> Cho ph\u00e9p vi\u1ebft CSS b\u1eb1ng Sass ho\u1eb7c Less, vi\u1ebft JavaScript b\u1eb1ng CoffeeScript.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>N\u00e9n v\u00e0 g\u1ed9p t\u1ec7p:<\/b><span style=\"font-weight: 400;\"> Gi\u1ea3m s\u1ed1 l\u01b0\u1ee3ng y\u00eau c\u1ea7u HTTP v\u00e0 k\u00edch th\u01b0\u1edbc t\u1ec7p, c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t t\u1ea3i trang.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Fingerprints:<\/b><span style=\"font-weight: 400;\"> Th\u00eam chu\u1ed7i hash v\u00e0o t\u00ean t\u1ec7p \u0111\u1ec3 h\u1ed7 tr\u1ee3 caching hi\u1ec7u qu\u1ea3.<\/span><\/li>\n<\/ul>\n<h3><b>Callback trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Callbacks<\/b><span style=\"font-weight: 400;\"> l\u00e0 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c g\u1ecdi t\u1ea1i c\u00e1c th\u1eddi \u0111i\u1ec3m c\u1ee5 th\u1ec3 trong v\u00f2ng \u0111\u1eddi c\u1ee7a m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng Active Record, nh\u01b0 tr\u01b0\u1edbc khi t\u1ea1o, sau khi c\u1eadp nh\u1eadt, ho\u1eb7c tr\u01b0\u1edbc khi x\u00f3a. Ch\u00fang cho ph\u00e9p b\u1ea1n th\u00eam logic t\u00f9y ch\u1ec9nh v\u00e0o qu\u00e1 tr\u00ecnh x\u1eed l\u00fd d\u1eef li\u1ec7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> User &lt; ApplicationRecord<\/span>\n<span style=\"font-weight: 400;\">\u00a0 before_save <\/span><span style=\"font-weight: 400;\">:normalize_name<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0 private<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> normalize_name<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">self<\/span><span style=\"font-weight: 400;\">.name = name.downcase.titleize<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h3><b>C\u00e1c lo\u1ea1i Callbacks trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00e1c lo\u1ea1i callback ph\u1ed5 bi\u1ebfn:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>before_validation<\/b><b>, <\/b><b>after_validation<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>before_save<\/b><b>, <\/b><b>around_save<\/b><b>, <\/b><b>after_save<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>before_create<\/b><b>, <\/b><b>around_create<\/b><b>, <\/b><b>after_create<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>before_update<\/b><b>, <\/b><b>around_update<\/b><b>, <\/b><b>after_update<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>before_destroy<\/b><b>, <\/b><b>around_destroy<\/b><b>, <\/b><b>after_destroy<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>after_commit<\/b><b>, <\/b><b>after_rollback<\/b><\/li>\n<\/ul>\n<h3><b>Polymorphic Association trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Polymorphic Association<\/b><span style=\"font-weight: 400;\"> cho ph\u00e9p m\u1ed9t model li\u00ean k\u1ebft v\u1edbi nhi\u1ec1u model kh\u00e1c nhau th\u00f4ng qua m\u1ed9t interface chung. V\u00ed d\u1ee5, model <\/span><span style=\"font-weight: 400;\">Comment<\/span><span style=\"font-weight: 400;\"> c\u00f3 th\u1ec3 thu\u1ed9c v\u1ec1 <\/span><span style=\"font-weight: 400;\">Post<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">Photo<\/span><span style=\"font-weight: 400;\">, ho\u1eb7c b\u1ea5t k\u1ef3 model n\u00e0o kh\u00e1c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00e1ch thi\u1ebft l\u1eadp:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> Comment &lt; ApplicationRecord<\/span>\n<span style=\"font-weight: 400;\">\u00a0 belongs_to <\/span><span style=\"font-weight: 400;\">:commentable<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">polymorphic:<\/span> <span style=\"font-weight: 400;\">true<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> Post &lt; ApplicationRecord<\/span>\n<span style=\"font-weight: 400;\">\u00a0 has_many <\/span><span style=\"font-weight: 400;\">:comments<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">as:<\/span> <span style=\"font-weight: 400;\">:commentable<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> Photo &lt; ApplicationRecord<\/span>\n<span style=\"font-weight: 400;\">\u00a0 has_many <\/span><span style=\"font-weight: 400;\">:comments<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">as:<\/span> <span style=\"font-weight: 400;\">:commentable<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><b>has_many :through<\/b><b> v\u00e0 <\/b><b>has_and_belongs_to_many<\/b><b> l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_and_belongs_to_many<\/b><b> (HABTM):<\/b><span style=\"font-weight: 400;\"> Thi\u1ebft l\u1eadp m\u1ed1i quan h\u1ec7 nhi\u1ec1u-nhi\u1ec1u tr\u1ef1c ti\u1ebfp gi\u1eefa hai model th\u00f4ng qua m\u1ed9t b\u1ea3ng join m\u00e0 kh\u00f4ng c\u00f3 model t\u01b0\u01a1ng \u1ee9ng. Kh\u00f4ng th\u1ec3 th\u00eam thu\u1ed9c t\u00ednh ho\u1eb7c logic v\u00e0o b\u1ea3ng join.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_many :through<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Thi\u1ebft l\u1eadp m\u1ed1i quan h\u1ec7 nhi\u1ec1u-nhi\u1ec1u th\u00f4ng qua m\u1ed9t model trung gian. Cho ph\u00e9p b\u1ea1n th\u00eam thu\u1ed9c t\u00ednh, x\u00e1c th\u1ef1c v\u00e0 callback v\u00e0o model trung gian n\u00e0y.<\/span><\/li>\n<\/ul>\n<p><b>N\u00ean s\u1eed d\u1ee5ng <\/b><b>has_many :through<\/b><b> khi:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u1ea1n c\u1ea7n l\u01b0u tr\u1eef th\u00eam th\u00f4ng tin trong b\u1ea3ng join.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u1ea1n mu\u1ed1n qu\u1ea3n l\u00fd m\u1ed1i quan h\u1ec7 ph\u1ee9c t\u1ea1p h\u01a1n.<\/span><\/li>\n<\/ul>\n<h3><b>Active Storage trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Active Storage<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t framework t\u00edch h\u1ee3p trong Rails 5.2 tr\u1edf l\u00ean, gi\u00fap qu\u1ea3n l\u00fd vi\u1ec7c upload v\u00e0 l\u01b0u tr\u1eef file m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng. N\u00f3 h\u1ed7 tr\u1ee3 l\u01b0u tr\u1eef file tr\u00ean nhi\u1ec1u d\u1ecbch v\u1ee5 nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Local disk<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Amazon S3<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Google Cloud Storage<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u1edbi Active Storage, b\u1ea1n c\u00f3 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u00ednh k\u00e8m m\u1ed9t ho\u1eb7c nhi\u1ec1u file v\u00e0o model.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">D\u1ec5 d\u00e0ng chuy\u1ec3n \u0111\u1ed5i gi\u1eefa c\u00e1c d\u1ecbch v\u1ee5 l\u01b0u tr\u1eef.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u1eed l\u00fd h\u00ecnh \u1ea3nh (thay \u0111\u1ed5i k\u00edch th\u01b0\u1edbc, chuy\u1ec3n \u0111\u1ed5i \u0111\u1ecbnh d\u1ea1ng).<\/span><\/li>\n<\/ul>\n<h3><b>Accessor Methods trong Ruby l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Accessor Methods<\/b><span style=\"font-weight: 400;\"> l\u00e0 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c gi\u00fap truy c\u1eadp v\u00e0 thay \u0111\u1ed5i gi\u00e1 tr\u1ecb c\u1ee7a bi\u1ebfn instance. Ruby cung c\u1ea5p c\u00e1c macro \u0111\u1ec3 t\u1ea1o c\u00e1c ph\u01b0\u01a1ng th\u1ee9c n\u00e0y m\u1ed9t c\u00e1ch t\u1ef1 \u0111\u1ed9ng:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>attr_reader<\/b><b>:<\/b><span style=\"font-weight: 400;\"> T\u1ea1o ph\u01b0\u01a1ng th\u1ee9c getter.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>attr_writer<\/b><b>:<\/b><span style=\"font-weight: 400;\"> T\u1ea1o ph\u01b0\u01a1ng th\u1ee9c setter.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>attr_accessor<\/b><b>:<\/b><span style=\"font-weight: 400;\"> T\u1ea1o c\u1ea3 getter v\u00e0 setter.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> User<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">attr_accessor<\/span> <span style=\"font-weight: 400;\">:name<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">user = User.new<\/span>\n<span style=\"font-weight: 400;\">user.name = <\/span><span style=\"font-weight: 400;\">\"Alice\"<\/span>\n<span style=\"font-weight: 400;\">puts user.name\u00a0 <\/span><span style=\"font-weight: 400;\"># Output: Alice<\/span><\/pre>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><b>super<\/b><b> v\u00e0 <\/b><b>super()<\/b><b> trong Ruby l\u00e0 g\u00ec?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>super<\/b><b>:<\/b><span style=\"font-weight: 400;\"> G\u1ecdi ph\u01b0\u01a1ng th\u1ee9c c\u00f9ng t\u00ean \u1edf l\u1edbp cha v\u1edbi t\u1ea5t c\u1ea3 c\u00e1c tham s\u1ed1 \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o ph\u01b0\u01a1ng th\u1ee9c hi\u1ec7n t\u1ea1i.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>super()<\/b><b>:<\/b><span style=\"font-weight: 400;\"> G\u1ecdi ph\u01b0\u01a1ng th\u1ee9c c\u00f9ng t\u00ean \u1edf l\u1edbp cha nh\u01b0ng kh\u00f4ng truy\u1ec1n b\u1ea5t k\u1ef3 tham s\u1ed1 n\u00e0o.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> Parent<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> greet<\/span><span style=\"font-weight: 400;\">(message)<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 puts message<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> Child &lt; Parent<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> greet<\/span><span style=\"font-weight: 400;\">(message)<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">super<\/span><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\"># Truy\u1ec1n tham s\u1ed1 message l\u00ean ph\u01b0\u01a1ng th\u1ee9c cha<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h3><b>C\u00e1c lo\u1ea1i Association trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Rails h\u1ed7 tr\u1ee3 c\u00e1c lo\u1ea1i association sau:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>belongs_to<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_one<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_many<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_many :through<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_one :through<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>has_and_belongs_to_many<\/b><\/li>\n<\/ul>\n<h3><b>Skip Callback<\/b><b> trong Rails ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 b\u1ecf qua c\u00e1c callback trong Rails b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">skip_callback<\/span><span style=\"font-weight: 400;\">. \u0110i\u1ec1u n\u00e0y h\u1eefu \u00edch khi b\u1ea1n mu\u1ed1n t\u1ea1m th\u1eddi v\u00f4 hi\u1ec7u h\u00f3a m\u1ed9t callback c\u1ee5 th\u1ec3.<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">Tuy nhi\u00ean<\/span><\/i><span style=\"font-weight: 400;\">, c\u1ea7n l\u01b0u \u00fd r\u1eb1ng vi\u1ec7c s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">skip_callback<\/span><span style=\"font-weight: 400;\"> c\u00f3 th\u1ec3 \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn to\u00e0n b\u1ed9 l\u1edbp v\u00e0 c\u00f3 th\u1ec3 g\u00e2y ra h\u1eadu qu\u1ea3 kh\u00f4ng mong mu\u1ed1n n\u1ebfu kh\u00f4ng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng c\u1ea9n th\u1eadn. Ngo\u00e0i ra, trong Rails 5 tr\u1edf l\u00ean, c\u00fa ph\u00e1p c\u1ee7a <\/span><span style=\"font-weight: 400;\">skip_callback<\/span><span style=\"font-weight: 400;\"> \u0111\u00e3 thay \u0111\u1ed5i v\u00e0 vi\u1ec7c s\u1eed d\u1ee5ng callback c\u0169ng c\u1ea7n tu\u00e2n theo c\u00e1c quy \u01b0\u1edbc m\u1edbi.<\/span><\/p>\n<p><b>C\u1eadp nh\u1eadt c\u00fa ph\u00e1p cho Rails 5 tr\u1edf l\u00ean:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Trong Rails 5+, b\u1ea1n c\u1ea7n ch\u1ec9 \u0111\u1ecbnh c\u00e1c t\u00f9y ch\u1ecdn khi s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">skip_callback<\/span><span style=\"font-weight: 400;\">. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> User &lt; ApplicationRecord<\/span>\n<span style=\"font-weight: 400;\">\u00a0 before_save <\/span><span style=\"font-weight: 400;\">:normalize_name<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\"># B\u1ecf qua callback :normalize_name<\/span>\n<span style=\"font-weight: 400;\">User.skip_callback(<\/span><span style=\"font-weight: 400;\">:save<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:before<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:normalize_name<\/span><span style=\"font-weight: 400;\">)<\/span><\/pre>\n<p><b>Khuy\u1ebfn c\u00e1o s\u1eed d\u1ee5ng conditional callbacks:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Thay v\u00ec b\u1ecf qua callback, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c \u0111i\u1ec1u ki\u1ec7n \u0111\u1ec3 ki\u1ec3m so\u00e1t khi n\u00e0o callback \u0111\u01b0\u1ee3c th\u1ef1c thi:<\/span><\/p>\n<pre>before_save :normalize_name, if: :should_normalize_name?\n\nprivate\n\ndef should_normalize_name?\n\u00a0 # \u0110i\u1ec1u ki\u1ec7n \u0111\u1ec3 th\u1ef1c thi callback\nend<\/pre>\n<h3><b>Concerns trong Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Concerns<\/b><span style=\"font-weight: 400;\"> l\u00e0 c\u00e1ch \u0111\u1ec3 chia s\u1ebb m\u00e3 ngu\u1ed3n gi\u1eefa c\u00e1c model ho\u1eb7c controller trong Rails. Ch\u00fang l\u00e0 c\u00e1c module \u0111\u01b0\u1ee3c \u0111\u1eb7t trong <\/span><span style=\"font-weight: 400;\">app\/models\/concerns<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">app\/controllers\/concerns<\/span><span style=\"font-weight: 400;\">. S\u1eed d\u1ee5ng Concerns gi\u00fap:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u00e1i s\u1eed d\u1ee5ng m\u00e3 ngu\u1ed3n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Gi\u1eef cho model v\u00e0 controller g\u1ecdn g\u00e0ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ed5 ch\u1ee9c m\u00e3 ngu\u1ed3n m\u1ed9t c\u00e1ch logic.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\"># app\/models\/concerns\/trackable.rb<\/span>\n<span style=\"font-weight: 400;\">module<\/span><span style=\"font-weight: 400;\"> Trackable<\/span>\n<span style=\"font-weight: 400;\">\u00a0 extend ActiveSupport::Concern<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0 included <\/span><span style=\"font-weight: 400;\">do<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 before_create <\/span><span style=\"font-weight: 400;\">:set_created_by<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> set_created_by<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">self<\/span><span style=\"font-weight: 400;\">.created_by = Current.user.id<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\"># app\/models\/post.rb<\/span>\n<span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> Post &lt; ApplicationRecord<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">include<\/span><span style=\"font-weight: 400;\"> Trackable<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h3><b>L\u1ec7nh <\/b><b>destroy<\/b><b> trong Ruby on Rails ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh <\/span><span style=\"font-weight: 400;\">destroy<\/span><span style=\"font-weight: 400;\"> x\u00f3a m\u1ed9t b\u1ea3n ghi kh\u1ecfi c\u01a1 s\u1edf d\u1eef li\u1ec7u v\u00e0 k\u00edch ho\u1ea1t c\u00e1c callback li\u00ean quan (nh\u01b0 <\/span><span style=\"font-weight: 400;\">before_destroy<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">after_destroy<\/span><span style=\"font-weight: 400;\">). N\u00f3 c\u0169ng s\u1ebd x\u00f3a c\u00e1c b\u1ea3n ghi li\u00ean quan d\u1ef1a tr\u00ean c\u00e1c t\u00f9y ch\u1ecdn <\/span><span style=\"font-weight: 400;\">dependent<\/span><span style=\"font-weight: 400;\"> trong association.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">@user.destroy\u00a0 <\/span><span style=\"font-weight: 400;\"># X\u00f3a ng\u01b0\u1eddi d\u00f9ng v\u00e0 k\u00edch ho\u1ea1t callback<\/span><\/pre>\n<h3><b>Ruby h\u1ed7 tr\u1ee3 Multiple Inheritance v\u00e0 Single Inheritance nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Single Inheritance:<\/b><span style=\"font-weight: 400;\"> Ruby h\u1ed7 tr\u1ee3 k\u1ebf th\u1eeba \u0111\u01a1n, ngh\u0129a l\u00e0 m\u1ed9t l\u1edbp ch\u1ec9 c\u00f3 th\u1ec3 k\u1ebf th\u1eeba t\u1eeb m\u1ed9t l\u1edbp cha duy nh\u1ea5t.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Multiple Inheritance:<\/b><span style=\"font-weight: 400;\"> Ruby kh\u00f4ng h\u1ed7 tr\u1ee3 k\u1ebf th\u1eeba \u0111a nh\u01b0ng cung c\u1ea5p module v\u00e0 mixin \u0111\u1ec3 m\u00f4 ph\u1ecfng h\u00e0nh vi n\u00e0y. B\u1eb1ng c\u00e1ch <\/span><span style=\"font-weight: 400;\">include<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">extend<\/span><span style=\"font-weight: 400;\"> c\u00e1c module, b\u1ea1n c\u00f3 th\u1ec3 th\u00eam c\u00e1c ph\u01b0\u01a1ng th\u1ee9c v\u00e0o l\u1edbp.<\/span><\/li>\n<\/ul>\n<h3><b>Hash trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>Hash<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t c\u1ea5u tr\u00fac d\u1eef li\u1ec7u l\u01b0u tr\u1eef c\u00e1c c\u1eb7p key-value. Trong Ruby, hash \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng r\u1ed9ng r\u00e3i \u0111\u1ec3 truy\u1ec1n tham s\u1ed1, c\u1ea5u h\u00ecnh v\u00e0 l\u01b0u tr\u1eef d\u1eef li\u1ec7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">person = { <\/span><span style=\"font-weight: 400;\">name:<\/span> <span style=\"font-weight: 400;\">\"Bob\"<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">age:<\/span> <span style=\"font-weight: 400;\">30<\/span><span style=\"font-weight: 400;\"> }<\/span>\n<span style=\"font-weight: 400;\">puts person[<\/span><span style=\"font-weight: 400;\">:name<\/span><span style=\"font-weight: 400;\">]\u00a0 <\/span><span style=\"font-weight: 400;\"># Output: Bob<\/span><\/pre>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa <\/b><b>Array#each<\/b><b> v\u00e0 <\/b><b>Array#map<\/b><b> l\u00e0 g\u00ec?<\/b><\/h3>\n<p><b>each<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Duy\u1ec7t qua t\u1eebng ph\u1ea7n t\u1eed trong m\u1ea3ng v\u00e0 th\u1ef1c thi m\u1ed9t kh\u1ed1i m\u00e3 cho m\u1ed7i ph\u1ea7n t\u1eed. Kh\u00f4ng tr\u1ea3 v\u1ec1 m\u1ea3ng m\u1edbi.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">[<\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">3<\/span><span style=\"font-weight: 400;\">].each { <\/span><span style=\"font-weight: 400;\">|n|<\/span><span style=\"font-weight: 400;\"> puts n }<\/span><\/pre>\n<p><b>map<\/b><b>:<\/b><span style=\"font-weight: 400;\"> Duy\u1ec7t qua t\u1eebng ph\u1ea7n t\u1eed, th\u1ef1c thi kh\u1ed1i m\u00e3 v\u00e0 tr\u1ea3 v\u1ec1 m\u1ed9t m\u1ea3ng m\u1edbi ch\u1ee9a k\u1ebft qu\u1ea3.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">squares = [<\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">3<\/span><span style=\"font-weight: 400;\">].map { <\/span><span style=\"font-weight: 400;\">|n|<\/span><span style=\"font-weight: 400;\"> n * n }\u00a0 <\/span><span style=\"font-weight: 400;\"># squares = [1, 4, 9]<\/span><\/pre>\n<h3><b>Ph\u01b0\u01a1ng th\u1ee9c <\/b><b>self.up<\/b><b> v\u00e0 <\/b><b>self.down<\/b><b> d\u00f9ng \u0111\u1ec3 l\u00e0m g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong c\u00e1c migration c\u0169, <\/span><span style=\"font-weight: 400;\">self.up<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">self.down<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 \u0111\u1ecbnh ngh\u0129a c\u00e1ch \u00e1p d\u1ee5ng v\u00e0 ho\u00e0n t\u00e1c thay \u0111\u1ed5i c\u01a1 s\u1edf d\u1eef li\u1ec7u.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>self.up<\/b><b>:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ecbnh ngh\u0129a c\u00e1c thay \u0111\u1ed5i c\u1ea7n \u00e1p d\u1ee5ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>self.down<\/b><b>:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ecbnh ngh\u0129a c\u00e1ch ho\u00e0n t\u00e1c c\u00e1c thay \u0111\u1ed5i.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Trong c\u00e1c phi\u00ean b\u1ea3n Rails m\u1edbi, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">change<\/span><span style=\"font-weight: 400;\"> thay th\u1ebf cho <\/span><span style=\"font-weight: 400;\">up<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">down<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><b>V\u00ed d\u1ee5 v\u1ec1 s\u1eed d\u1ee5ng <\/b><b>change<\/b><b>:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> AddEmailToUsers &lt; ActiveRecord::Migration[6.1]<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> change<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 add_column <\/span><span style=\"font-weight: 400;\">:users<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:email<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:string<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<p><b>Khi c\u1ea7n s\u1eed d\u1ee5ng <\/b><b>up<\/b><b> v\u00e0 <\/b><b>down<\/b><b>:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">N\u1ebfu thay \u0111\u1ed5i kh\u00f4ng th\u1ec3 \u0111\u1ea3o ng\u01b0\u1ee3c t\u1ef1 \u0111\u1ed9ng, b\u1ea1n n\u00ean s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">up<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">down<\/span><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class<\/span><span style=\"font-weight: 400;\"> ChangeDataTypeForPrice &lt; ActiveRecord::Migration[6.1]<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> up<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 change_column <\/span><span style=\"font-weight: 400;\">:products<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:price<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:string<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> down<\/span>\n<span style=\"font-weight: 400;\">\u00a0 \u00a0 change_column <\/span><span style=\"font-weight: 400;\">:products<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:price<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">:integer<\/span>\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">end<\/span>\n<span style=\"font-weight: 400;\">end<\/span><\/pre>\n<h3><b>yield<\/b><b> trong Ruby on Rails l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">yield<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong ph\u01b0\u01a1ng th\u1ee9c \u0111\u1ec3 g\u1ecdi \u0111\u1ebfn m\u1ed9t kh\u1ed1i m\u00e3 \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o khi g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c \u0111\u00f3. Trong Rails, <\/span><span style=\"font-weight: 400;\">yield<\/span><span style=\"font-weight: 400;\"> th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong layout \u0111\u1ec3 ch\u00e8n n\u1ed9i dung c\u1ee7a view.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">&lt;!-- layout.html.erb --&gt;<\/span>\n<span style=\"font-weight: 400;\">&lt;html&gt;<\/span>\n<span style=\"font-weight: 400;\">&lt;head&gt;<\/span>\n<span style=\"font-weight: 400;\">\u00a0 &lt;title&gt;My App&lt;<\/span><span style=\"font-weight: 400;\">\/title&gt;<\/span>\n<span style=\"font-weight: 400;\">&lt;\/head<\/span><span style=\"font-weight: 400;\">&gt;<\/span>\n<span style=\"font-weight: 400;\">&lt;body&gt;<\/span>\n<span style=\"font-weight: 400;\">\u00a0 &lt;%= <\/span><span style=\"font-weight: 400;\">yield<\/span><span style=\"font-weight: 400;\"> %&gt;<\/span>\n<span style=\"font-weight: 400;\">&lt;<\/span><span style=\"font-weight: 400;\">\/body&gt;<\/span>\n<span style=\"font-weight: 400;\">&lt;\/html<\/span><span style=\"font-weight: 400;\">&gt;<\/span><\/pre>\n<h3><b> Closure trong Ruby l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong Ruby, <\/span><b>closure<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t kh\u1ed1i m\u00e3 (code block) c\u00f3 kh\u1ea3 n\u0103ng &#8220;ghi nh\u1edb&#8221; ng\u1eef c\u1ea3nh n\u01a1i n\u00f3 \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a, bao g\u1ed3m c\u00e1c bi\u1ebfn c\u1ee5c b\u1ed9. \u0110i\u1ec1u n\u00e0y cho ph\u00e9p kh\u1ed1i m\u00e3 truy c\u1eadp v\u00e0 s\u1eed d\u1ee5ng c\u00e1c bi\u1ebfn ngo\u00e0i ph\u1ea1m vi hi\u1ec7n t\u1ea1i khi \u0111\u01b0\u1ee3c th\u1ef1c thi sau n\u00e0y. Closure gi\u00fap b\u1ea1n truy\u1ec1n c\u00e1c kh\u1ed1i m\u00e3 linh ho\u1ea1t trong ch\u01b0\u01a1ng tr\u00ecnh v\u00e0 th\u1ef1c hi\u1ec7n ch\u00fang v\u1edbi ng\u1eef c\u1ea3nh ban \u0111\u1ea7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Trong Ruby, closure \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n th\u00f4ng qua:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Block:<\/b><span style=\"font-weight: 400;\"> Kh\u1ed1i m\u00e3 kh\u00f4ng t\u00ean \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o ph\u01b0\u01a1ng th\u1ee9c, s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">{}<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">do&#8230;end<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Proc:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ed1i t\u01b0\u1ee3ng l\u01b0u tr\u1eef m\u1ed9t block, c\u00f3 th\u1ec3 g\u00e1n v\u00e0o bi\u1ebfn ho\u1eb7c truy\u1ec1n l\u00e0m tham s\u1ed1.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Lambda:<\/b><span style=\"font-weight: 400;\"> M\u1ed9t d\u1ea1ng \u0111\u1eb7c bi\u1ec7t c\u1ee7a Proc v\u1edbi c\u00e1ch x\u1eed l\u00fd tham s\u1ed1 v\u00e0 <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> kh\u00e1c bi\u1ec7t.<\/span><\/li>\n<\/ul>\n<p><b>V\u00ed d\u1ee5 s\u1eed d\u1ee5ng Proc l\u00e0m closure:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">def<\/span><span style=\"font-weight: 400;\"> multiplier<\/span><span style=\"font-weight: 400;\">(factor)<\/span>\n<span style=\"font-weight: 400;\">\u00a0 Proc.new { <\/span><span style=\"font-weight: 400;\">|n|<\/span><span style=\"font-weight: 400;\"> n * factor }<\/span>\n<span style=\"font-weight: 400;\">end<\/span>\n\n<span style=\"font-weight: 400;\">times_two = multiplier(<\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\">)<\/span>\n<span style=\"font-weight: 400;\">puts times_two.call(<\/span><span style=\"font-weight: 400;\">5<\/span><span style=\"font-weight: 400;\">)\u00a0 <\/span><span style=\"font-weight: 400;\"># Output: 10<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong v\u00ed d\u1ee5 tr\u00ean, <\/span><span style=\"font-weight: 400;\">times_two<\/span><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t closure gi\u1eef l\u1ea1i bi\u1ebfn <\/span><span style=\"font-weight: 400;\">factor<\/span><span style=\"font-weight: 400;\"> v\u1edbi gi\u00e1 tr\u1ecb <\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\">, cho ph\u00e9p nh\u00e2n b\u1ea5t k\u1ef3 s\u1ed1 n\u00e0o v\u1edbi <\/span><span style=\"font-weight: 400;\">2<\/span><span style=\"font-weight: 400;\"> khi g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c <\/span><span style=\"font-weight: 400;\">call<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><b>\u1ee8ng d\u1ee5ng c\u1ee7a closure:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Callback v\u00e0 Event Handling:<\/b><span style=\"font-weight: 400;\"> Truy\u1ec1n h\u00e0nh vi t\u00f9y ch\u1ec9nh v\u00e0o ph\u01b0\u01a1ng th\u1ee9c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1eadp tr\u00ecnh h\u00e0m:<\/b><span style=\"font-weight: 400;\"> T\u1ea1o c\u00e1c h\u00e0m b\u1eadc cao, h\u1ed7 tr\u1ee3 k\u1ef9 thu\u1eadt nh\u01b0 currying.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00e1i s\u1eed d\u1ee5ng m\u00e3:<\/b><span style=\"font-weight: 400;\"> Vi\u1ebft m\u00e3 linh ho\u1ea1t v\u00e0 d\u1ec5 b\u1ea3o tr\u00ec h\u01a1n.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Closure l\u00e0 m\u1ed9t kh\u00e1i ni\u1ec7m m\u1ea1nh m\u1ebd trong Ruby, gi\u00fap b\u1ea1n vi\u1ebft m\u00e3 ng\u1eafn g\u1ecdn, linh ho\u1ea1t v\u00e0 bi\u1ec3u \u0111\u1ea1t h\u01a1n.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Cac_meo_phong_van_va_chuan_bi_cho_Ruby_on_Rails\"><\/span><strong>C\u00e1c m\u1eb9o ph\u1ecfng v\u1ea5n v\u00e0 chu\u1ea9n b\u1ecb cho Ruby on Rails<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 th\u00e0nh c\u00f4ng trong bu\u1ed5i ph\u1ecfng v\u1ea5n v\u1ec1 Ruby on Rails, b\u1ea1n c\u1ea7n kh\u00f4ng ch\u1ec9 n\u1eafm v\u1eefng ki\u1ebfn th\u1ee9c k\u1ef9 thu\u1eadt m\u00e0 c\u00f2n ph\u1ea3i chu\u1ea9n b\u1ecb k\u1ef9 l\u01b0\u1ee1ng v\u1ec1 m\u1ecdi m\u1eb7t. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 m\u1eb9o gi\u00fap b\u1ea1n t\u1ef1 tin v\u00e0 g\u00e2y \u1ea5n t\u01b0\u1ee3ng t\u1ed1t v\u1edbi nh\u00e0 tuy\u1ec3n d\u1ee5ng:<\/span><\/p>\n<p><strong>Hi\u1ec3u r\u00f5 v\u1ec1 Ruby v\u00e0 Rails:<\/strong><\/p>\n<ul>\n<li>N\u1eafm v\u1eefng ki\u1ebfn th\u1ee9c c\u01a1 b\u1ea3n:<span style=\"font-weight: 400;\"> \u0110\u1ea3m b\u1ea3o b\u1ea1n hi\u1ec3u r\u00f5 c\u00fa ph\u00e1p Ruby, c\u1ea5u tr\u00fac c\u1ee7a Rails, v\u00e0 c\u00e1ch hai y\u1ebfu t\u1ed1 n\u00e0y k\u1ebft h\u1ee3p v\u1edbi nhau.<\/span><\/li>\n<li>C\u1eadp nh\u1eadt phi\u00ean b\u1ea3n m\u1edbi nh\u1ea5t:<span style=\"font-weight: 400;\"> Rails li\u00ean t\u1ee5c c\u1eadp nh\u1eadt v\u00e0 c\u1ea3i ti\u1ebfn; h\u00e3y \u0111\u1ea3m b\u1ea3o b\u1ea1n bi\u1ebft v\u1ec1 c\u00e1c t\u00ednh n\u0103ng m\u1edbi v\u00e0 s\u1ef1 thay \u0111\u1ed5i trong c\u00e1c phi\u00ean b\u1ea3n g\u1ea7n \u0111\u00e2y.<\/span><\/li>\n<li>\u00d4n t\u1eadp v\u1edbi <a href=\"\/blog\/ruby-on-rails-la-gi\/\" target=\"_blank\" rel=\"noopener\"><strong>17 t\u00e0i li\u1ec7u h\u1ecdc Ruby on Rails m\u1edbi nh\u1ea5t<\/strong><\/a>.<\/li>\n<\/ul>\n<p><strong>Th\u1ef1c h\u00e0nh th\u1ef1c t\u1ebf:<\/strong><\/p>\n<ul>\n<li>X\u00e2y d\u1ef1ng d\u1ef1 \u00e1n c\u00e1 nh\u00e2n:<span style=\"font-weight: 400;\"> T\u1ea1o m\u1ed9t ho\u1eb7c nhi\u1ec1u \u1ee9ng d\u1ee5ng web s\u1eed d\u1ee5ng Rails \u0111\u1ec3 th\u1ec3 hi\u1ec7n k\u1ef9 n\u0103ng c\u1ee7a b\u1ea1n.<\/span><\/li>\n<li>\u0110\u00f3ng g\u00f3p cho m\u00e3 ngu\u1ed3n m\u1edf:<span style=\"font-weight: 400;\"> Tham gia v\u00e0o c\u00e1c d\u1ef1 \u00e1n tr\u00ean GitHub \u0111\u1ec3 t\u00edch l\u0169y kinh nghi\u1ec7m v\u00e0 th\u1ec3 hi\u1ec7n s\u1ef1 ch\u1ee7 \u0111\u1ed9ng.<\/span><\/li>\n<\/ul>\n<p><strong>Chu\u1ea9n b\u1ecb c\u00e1c c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n:<\/strong><\/p>\n<ul>\n<li>\u00d4n t\u1eadp c\u00e1c c\u00e2u h\u1ecfi k\u1ef9 thu\u1eadt:<span style=\"font-weight: 400;\"> S\u1eed d\u1ee5ng danh s\u00e1ch c\u00e2u h\u1ecfi trong b\u00e0i vi\u1ebft n\u00e0y \u0111\u1ec3 luy\u1ec7n t\u1eadp tr\u1ea3 l\u1eddi.<\/span><\/li>\n<li>Th\u1ef1c h\u00e0nh gi\u1ea3i th\u00edch kh\u00e1i ni\u1ec7m:<span style=\"font-weight: 400;\"> H\u00e3y t\u1eadp gi\u1ea3i th\u00edch c\u00e1c kh\u00e1i ni\u1ec7m ph\u1ee9c t\u1ea1p m\u1ed9t c\u00e1ch \u0111\u01a1n gi\u1ea3n v\u00e0 d\u1ec5 hi\u1ec3u.<\/span><\/li>\n<li>Luy\u1ec7n t\u1eadp thu\u1eadt to\u00e1n:<span style=\"font-weight: 400;\"> M\u1eb7c d\u00f9 Rails t\u1eadp trung v\u00e0o ph\u00e1t tri\u1ec3n \u1ee9ng d\u1ee5ng web, vi\u1ec7c hi\u1ec3u bi\u1ebft v\u1ec1 thu\u1eadt to\u00e1n v\u00e0 c\u1ea5u tr\u00fac d\u1eef li\u1ec7u v\u1eabn r\u1ea5t quan tr\u1ecdng.<\/span><\/li>\n<li>Gi\u1ea3i quy\u1ebft c\u00e1c b\u00e0i t\u1eadp l\u1eadp tr\u00ecnh:<span style=\"font-weight: 400;\"> S\u1eed d\u1ee5ng c\u00e1c trang web nh\u01b0 LeetCode, HackerRank \u0111\u1ec3 r\u00e8n luy\u1ec7n k\u1ef9 n\u0103ng.<\/span><\/li>\n<\/ul>\n<p><strong>Hi\u1ec3u v\u1ec1 c\u00f4ng ty v\u00e0 v\u1ecb tr\u00ed \u1ee9ng tuy\u1ec3n:<\/strong><\/p>\n<ul>\n<li>Nghi\u00ean c\u1ee9u c\u00f4ng ty:<span style=\"font-weight: 400;\"> T\u00ecm hi\u1ec3u v\u1ec1 s\u1ea3n ph\u1ea9m, d\u1ecbch v\u1ee5, v\u00e0 c\u00f4ng ngh\u1ec7 m\u00e0 c\u00f4ng ty s\u1eed d\u1ee5ng.<\/span><\/li>\n<li>Chu\u1ea9n b\u1ecb c\u00e2u h\u1ecfi cho nh\u00e0 tuy\u1ec3n d\u1ee5ng:<span style=\"font-weight: 400;\"> Th\u1ec3 hi\u1ec7n s\u1ef1 quan t\u00e2m b\u1eb1ng c\u00e1ch \u0111\u1eb7t nh\u1eefng c\u00e2u h\u1ecfi li\u00ean quan \u0111\u1ebfn d\u1ef1 \u00e1n ho\u1eb7c v\u0103n h\u00f3a c\u00f4ng ty.<\/span><\/li>\n<\/ul>\n<p><strong>C\u1ea3i thi\u1ec7n k\u1ef9 n\u0103ng m\u1ec1m:<\/strong><\/p>\n<ul>\n<li>K\u1ef9 n\u0103ng giao ti\u1ebfp:<span style=\"font-weight: 400;\"> Kh\u1ea3 n\u0103ng truy\u1ec1n \u0111\u1ea1t \u00fd t\u01b0\u1edfng r\u00f5 r\u00e0ng v\u00e0 hi\u1ec7u qu\u1ea3 l\u00e0 r\u1ea5t quan tr\u1ecdng.<\/span><\/li>\n<li>L\u00e0m vi\u1ec7c nh\u00f3m:<span style=\"font-weight: 400;\"> H\u00e3y chu\u1ea9n b\u1ecb \u0111\u1ec3 th\u1ea3o lu\u1eadn v\u1ec1 kinh nghi\u1ec7m l\u00e0m vi\u1ec7c nh\u00f3m v\u00e0 c\u00e1ch b\u1ea1n gi\u1ea3i quy\u1ebft xung \u0111\u1ed9t.<\/span><\/li>\n<li>Gi\u1eef b\u00ecnh t\u0129nh v\u00e0 t\u1ef1 tin:<span style=\"font-weight: 400;\"> Th\u1ef1c h\u00e0nh c\u00e1c k\u1ef9 thu\u1eadt gi\u1ea3m c\u0103ng th\u1eb3ng nh\u01b0 h\u00edt th\u1edf s\u00e2u.<\/span><\/li>\n<li>T\u00edch c\u1ef1c v\u00e0 nhi\u1ec7t t\u00ecnh:<span style=\"font-weight: 400;\"> Th\u1ec3 hi\u1ec7n \u0111am m\u00ea c\u1ee7a b\u1ea1n \u0111\u1ed1i v\u1edbi l\u1eadp tr\u00ecnh v\u00e0 Ruby on Rails.<\/span><\/li>\n<\/ul>\n<p><strong>K\u1ef3 v\u1ecdng g\u00ec \u1edf bu\u1ed5i ph\u1ecfng v\u1ea5n:<\/strong><\/p>\n<ul>\n<li>C\u00e2u h\u1ecfi v\u1ec1 kinh nghi\u1ec7m th\u1ef1c t\u1ebf:<span style=\"font-weight: 400;\"> Nh\u00e0 tuy\u1ec3n d\u1ee5ng c\u00f3 th\u1ec3 h\u1ecfi v\u1ec1 c\u00e1c d\u1ef1 \u00e1n b\u1ea1n \u0111\u00e3 l\u00e0m, vai tr\u00f2 c\u1ee5 th\u1ec3 c\u1ee7a b\u1ea1n, v\u00e0 k\u1ebft qu\u1ea3 \u0111\u1ea1t \u0111\u01b0\u1ee3c.<\/span><\/li>\n<li>B\u00e0i t\u1eadp coding tr\u1ef1c ti\u1ebfp:<span style=\"font-weight: 400;\"> C\u00f3 th\u1ec3 b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u vi\u1ebft m\u00e3 ngay trong bu\u1ed5i ph\u1ecfng v\u1ea5n, h\u00e3y chu\u1ea9n b\u1ecb cho \u0111i\u1ec1u n\u00e0y.<\/span><\/li>\n<li>Th\u1ea3o lu\u1eadn v\u1ec1 ki\u1ebfn tr\u00fac v\u00e0 thi\u1ebft k\u1ebf:<span style=\"font-weight: 400;\"> B\u1ea1n c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c h\u1ecfi v\u1ec1 c\u00e1ch b\u1ea1n thi\u1ebft k\u1ebf m\u1ed9t \u1ee9ng d\u1ee5ng ho\u1eb7c gi\u1ea3i quy\u1ebft m\u1ed9t v\u1ea5n \u0111\u1ec1 k\u1ef9 thu\u1eadt c\u1ee5 th\u1ec3.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket_cau_hoi_phong_van_Ruby_on_Rails\"><\/span><b>T\u1ed5ng k\u1ebft c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Ch\u00fang ta v\u1eeba c\u00f9ng nhau kh\u00e1m ph\u00e1 h\u01a1n 30 c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao. Vi\u1ec7c n\u1eafm v\u1eefng nh\u1eefng ki\u1ebfn th\u1ee9c n\u00e0y kh\u00f4ng ch\u1ec9 gi\u00fap b\u1ea1n t\u1ef1 tin h\u01a1n trong c\u00e1c bu\u1ed5i ph\u1ecfng v\u1ea5n m\u00e0 c\u00f2n c\u1ee7ng c\u1ed1 k\u1ef9 n\u0103ng l\u1eadp tr\u00ecnh c\u1ee7a b\u1ea1n. <\/span>Ch\u00fac b\u1ea1n th\u00e0nh c\u00f4ng v\u00e0 s\u1edbm \u0111\u1ea1t \u0111\u01b0\u1ee3c v\u1ecb tr\u00ed mong mu\u1ed1n v\u1edbi Ruby on Rails!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng b\u1ea1n \u0111ang ng\u1ed3i trong m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n, v\u00e0 nh\u00e0 tuy\u1ec3n d\u1ee5ng h\u1ecfi: &#8220;B\u1ea1n c\u00f3 th\u1ec3 gi\u1ea3i th\u00edch ORM trong Ruby on Rails l\u00e0 g\u00ec kh\u00f4ng?&#8221; B\u1ea1n s\u1ebd tr\u1ea3 l\u1eddi nh\u01b0 th\u1ebf n\u00e0o \u0111\u1ec3 g\u00e2y \u1ea5n t\u01b0\u1ee3ng v\u00e0 th\u1ec3 hi\u1ec7n ki\u1ebfn th\u1ee9c s\u00e2u r\u1ed9ng c\u1ee7a m\u00ecnh? \u0110\u1eebng lo l\u1eafng! B\u00e0i vi\u1ebft n\u00e0y [&hellip;]<\/p>\n","protected":false},"author":222,"featured_media":84516,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109,105],"tags":[],"class_list":["post-87970","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it","category-phong-van-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p - ITviec Blog<\/title>\n<meta name=\"description\" content=\"N\u1eafm v\u1eefng 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails sau \u0111\u00e2y \u0111\u1ec3 trang b\u1ecb nh\u1eefng ki\u1ebfn th\u1ee9c c\u1ea7n thi\u1ebft \u0111\u1ec3 t\u1ef1 tin &quot;chinh ph\u1ee5c&quot; nh\u00e0 tuy\u1ec3n d\u1ee5ng.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p\" \/>\n<meta property=\"og:description\" content=\"H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng b\u1ea1n \u0111ang ng\u1ed3i trong m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n, v\u00e0 nh\u00e0 tuy\u1ec3n d\u1ee5ng h\u1ecfi: &quot;B\u1ea1n c\u00f3 th\u1ec3 gi\u1ea3i th\u00edch ORM trong Ruby on Rails l\u00e0 g\u00ec kh\u00f4ng?&quot; B\u1ea1n s\u1ebd tr\u1ea3 l\u1eddi\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-25T09:50:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-17T08:11:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/cau-hoi-phong-van-Ruby-on-Rails-vippro.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"790\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nguy\u1ec5n H\u1eefu V\u0103n\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nguy\u1ec5n H\u1eefu V\u0103n\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"26 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p - ITviec Blog","description":"N\u1eafm v\u1eefng 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails sau \u0111\u00e2y \u0111\u1ec3 trang b\u1ecb nh\u1eefng ki\u1ebfn th\u1ee9c c\u1ea7n thi\u1ebft \u0111\u1ec3 t\u1ef1 tin \"chinh ph\u1ee5c\" nh\u00e0 tuy\u1ec3n d\u1ee5ng.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/","og_locale":"vi_VN","og_type":"article","og_title":"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p","og_description":"H\u00e3y t\u01b0\u1edfng t\u01b0\u1ee3ng b\u1ea1n \u0111ang ng\u1ed3i trong m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n, v\u00e0 nh\u00e0 tuy\u1ec3n d\u1ee5ng h\u1ecfi: \"B\u1ea1n c\u00f3 th\u1ec3 gi\u1ea3i th\u00edch ORM trong Ruby on Rails l\u00e0 g\u00ec kh\u00f4ng?\" B\u1ea1n s\u1ebd tr\u1ea3 l\u1eddi","og_url":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-03-25T09:50:59+00:00","article_modified_time":"2025-06-17T08:11:47+00:00","og_image":[{"width":1500,"height":790,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/cau-hoi-phong-van-Ruby-on-Rails-vippro.jpg","type":"image\/jpeg"}],"author":"Nguy\u1ec5n H\u1eefu V\u0103n","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Nguy\u1ec5n H\u1eefu V\u0103n","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"26 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/"},"author":{"name":"Nguy\u1ec5n H\u1eefu V\u0103n","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/a77cc13f89eaa58f59d8772448febe5f"},"headline":"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p","datePublished":"2025-03-25T09:50:59+00:00","dateModified":"2025-06-17T08:11:47+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/"},"wordCount":6816,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/cau-hoi-phong-van-Ruby-on-Rails-vippro.jpg","articleSection":["Chuy\u00ean m\u00f4n IT","Ph\u1ecfng v\u1ea5n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/","url":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/","name":"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/cau-hoi-phong-van-Ruby-on-Rails-vippro.jpg","datePublished":"2025-03-25T09:50:59+00:00","dateModified":"2025-06-17T08:11:47+00:00","description":"N\u1eafm v\u1eefng 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails sau \u0111\u00e2y \u0111\u1ec3 trang b\u1ecb nh\u1eefng ki\u1ebfn th\u1ee9c c\u1ea7n thi\u1ebft \u0111\u1ec3 t\u1ef1 tin \"chinh ph\u1ee5c\" nh\u00e0 tuy\u1ec3n d\u1ee5ng.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/cau-hoi-phong-van-Ruby-on-Rails-vippro.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/12\/cau-hoi-phong-van-Ruby-on-Rails-vippro.jpg","width":1500,"height":790,"caption":"ca\u0302u ho\u0309i pho\u0309ng va\u0302\u0301n Ruby on Rails - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-ruby-on-rails-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u1ee8ng tuy\u1ec3n &amp; Th\u0103ng ti\u1ebfn","item":"https:\/\/itviec.com\/blog\/ung-tuyen-va-thang-tien\/"},{"@type":"ListItem","position":2,"name":"Ph\u1ecfng v\u1ea5n IT","item":"https:\/\/itviec.com\/blog\/ung-tuyen-va-thang-tien\/phong-van-it\/"},{"@type":"ListItem","position":3,"name":"Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Ruby on Rails th\u01b0\u1eddng g\u1eb7p"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/a77cc13f89eaa58f59d8772448febe5f","name":"Nguy\u1ec5n H\u1eefu V\u0103n","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/TR-Nguyen-Huu-Van-vippro-e1712136004193-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/TR-Nguyen-Huu-Van-vippro-e1712136004193-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/TR-Nguyen-Huu-Van-vippro-e1712136004193-100x100.jpg","caption":"Nguy\u1ec5n H\u1eefu V\u0103n"},"url":"https:\/\/itviec.com\/blog\/author\/nguyen-huu-van-2\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/222"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=87970"}],"version-history":[{"count":2,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87970\/revisions"}],"predecessor-version":[{"id":88199,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87970\/revisions\/88199"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/84516"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=87970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=87970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=87970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}