Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails: specify list of items in yml

I want to specify resource authorisation info in yml file. admin can create an employee and can only view company.

I used YAML::load method to load this file.

If i use - symbol for multiple permission (action, resource pair) it gives parsing error. If i remove - symbol then it only picks first action resource pair. I think load method expect 1 space indentation while parsing and if i specify - then one space indentation condition is violated that is reason for error. What is possible solution for this.

if i use - symbol for listing

admin:
 - action: create
   resource: employee
 - action: show
   resource: company

if i do not use - symbol for listing

admin:
 action: create
 resource: employee
 action: show
 resource: company
like image 302
Maddy.Shik Avatar asked May 24 '11 18:05

Maddy.Shik


1 Answers

not sure if this helps, but when i try to load the first example, it works for me. Maybe the indentation is not correct?

anyway, this works here:

require "YAML"

something = YAML.load_file("admin.yaml")

oh yes, let me add the admin.yaml that works for me:

admin:
  - action: create
    resource: employee
  - action: show
    resource: company
like image 62
mkro Avatar answered Sep 20 '22 15:09

mkro