4

I've been playing a lot with Volt lately, and would like to figure out how to create an Admin area. The documentation has a section on restricting models for users, but it's still in the TODO list. Would like to know if there is an elegant way to do this yet?

I've figured out how to check whether a user is logged in or not, but would be cool to add some kind of role management (like the cancancan gem for RoR).

I'm new to all of this so I hope this isn't a stupid question, maybe I'm missing something obvious - but any help would be greatly appreciated!

Adam Cooper
  • 936
  • 11
  • 16

2 Answers2

1

I was trying to do the same thing, but I found this one here. So it seems to be work-in-progress.

:(

@jjuliano: March 2 2015

so roles aren't built in directly, but it will be really easy to add that in. @ryanstout will it be something like this?

 def admin?
   current_user._permission == :admin
 end

class Todo < Volt::Model
   if admin?
     permissions do |state|
       allow
     end
   end
end

@ryanstout: March 2 2015

more like this:

class Todo < Volt::Model
  permissions do
      allow if admin?
  end

  def admin?
    Volt.user.admin?
  end
end
Ich
  • 1,350
  • 16
  • 27
1

I've been playing with using components to render different "sections" of a web app.

For example, in my index.html I have something like the following:

{{ if Volt.current_user.is_admin }}
  <:admin_section/>
{{ else }}
  <:peon_section/>
{{ end }}

where my app has two components, admin_section and peon_section

For more information about components, see the volt user docs at http://docs.voltframework.com/en/docs/components.html

Jason Southwell
  • 351
  • 2
  • 9