No products in the cart.


Cách gọi helper trong ruby on rails
Chúng ta cần thực hiện các bước sau:
Đầu tiên
1. Trong helper file tạo ra một hàm
module DashboardsHelper def genarate_calendar @data = 'feb' end end
2. Trong controller file include helper vào
class DashboardsController < ApplicationController include DashboardsHelper def index @calendar = genarate_calendar end end
trong đây chúng ta include file helper vào và gọi luôn hàm đã taojt rong helper
3. Trả dữ liệu cho view
và xem thử data variable của chúng ta bây giờ như thế nào?
<%= render plain: @calendar.inspect %>
Thanks for reading!
Các bài viết không xem thì tiếc:
- HỌC AJAX CƠ BẢN | ĐÔ TRỊNH
- Rails ExecJS::ProgramError in View
- Làm tròn số phút lên 5 trong java
- Cách dump data trong Ruby
- Làm việc với font trong Android
- Siêu tổng hợp android code snippets (cập nhật thường xuyên)
- Cách tạo Sticky Sidebar với jQuery
- Tại sao đã thêm vào file gitignore rồi mà không có tác dụng?
- “Các câu lệnh git thông dụng” cực cần thiết cho developer
- Select where like trong Ruby On Rails
- Thay đổi tiêu đề, định dạng datepicker jQuery
- Tuyển lập trình viên iOS dotrinh.com
- Mẹo tìm kiếm cực hay trong Sublime
- Giải phương trình bậc 2 bằng Ruby
- Rails: undefined method `+’ for nil:NilClass
2 Comments