How to convert string to YAML in Ruby 2.3.0? -
i using delayed_job in application , showing info jobs. ability show id , priority attributes couldn't show handler details.
in view, when try view details of job:
<% @jobs.each |item| %> <% obj = yaml.load(item.to_yaml) %> <%= obj.inspect %> <% end %>
when use inspect, getting details as:
#<delayed::backend::activerecord::job id: 51, priority: 0, attempts: 0, handler: "--- !ruby/object:delayed::performablemailer\nobject...", last_error: nil, run_at: "2016-08-25 19:56:44", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2016-08-25 19:56:44", updated_at: "2016-08-25 19:56:44", queue: nil>
now need method_name handler, this, inorder list details, used
<%= obj.handler.inspect %>
it gave:
"--- !ruby/object:delayed::performablemailer\nobject: !ruby/class 'subscriptionnotifier'\nmethod_name: :welcome\nargs:\n- !ruby/object:user\n raw_attributes:\n deleted_at: \n name: espn star\n email: esp@test.com\n encrypted_password: \"$2a$10$jlv1bljcxpto4ithnkkvnoze.us6lmgdtkuvdniw4dftk8vzkx1os\"\n phone: ''\n website: ''\n designations: ''\n id: 22\n reset_password_token: \n reset_password_sent_at: \n remember_created_at: \n sign_in_count: '0'\n on
for showing method_name, think should make above string yaml, tried:
<% obj = yaml.load(item.handler.to_yaml) %>
no luck. please me how can convert yaml or how can show method_name?
i think should work:
<% @jobs.each |job| %> <%= yaml.load(job.handler)["method_name"] %> <% end %>
as in job.handler
yaml saved, can parse , access method_name
[].
Comments
Post a Comment