
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:
- Siêu tổng hợp android code snippets (cập nhật thường xuyên)
- HỌC AJAX CƠ BẢN | ĐÔ TRỊNH
- Làm tròn số phút lên 5 trong java
- “Các câu lệnh git thông dụng” cực cần thiết cho developer
- Rails ExecJS::ProgramError in View
- Cách dump data trong Ruby
- Làm việc với font trong Android
- Giải phương trình bậc 2 bằng Ruby
- Select where like trong Ruby On Rails
- Tại sao đã thêm vào file gitignore rồi mà không có tác dụng?
- Rails: undefined method `+’ for nil:NilClass
- Cách tạo Sticky Sidebar với jQuery
- Thay đổi tiêu đề, định dạng datepicker jQuery
- Mẹo tìm kiếm cực hay trong Sublime
- Tuyển lập trình viên iOS dotrinh.com


2 Comments