我想通過序列化哈希來爲我的應用程序構建一個默認清單。我不知道如何將我的setup_checklist哈希中的信息提取到我的視圖中。任何幫助表示讚賞。查看序列化的哈希軌道
這裏是我的用戶模型
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
serialize :checklist, Hash
before_create :setup_checklist
private
def setup_checklist
self.checklist = {
"Organize Your Finances" => false,
"Approval Letter" => false,
"Get a Real Estate Agent and look for houses" => false,
"Find lawyer" => false,
"Get the mortgage" => false,
"Apprisal and inspection" => false,
"Close the deal" => false
}
end
end
我view.html.erb
<%= form_for :checklist do |f| %>
<%= f.check_box :checklist %>
<% end %>
我知道我還差得遠,但在正確的方向轉舵將是巨大的