| title |
|---|
Hyper-Mesh Docs |
Sometimes you need to figure out what connections are available, or what attributes are readable etc.
Its usually all to do with your policies, but perhaps you just need a little investigation.
You can bring up a console within the controller context by browsing localhost:3000/rr/console
Note: change rr to wherever you are mounting HyperMesh in your routes file.
Note: in rails 4, you will need to add the gem 'web-console' to your development section
Within the context you have access to session.id and current acting_user which you will need, plus some helper methods to reduce typing
-
Getting auto connection channels:
channels(session_id = session.id, user = acting_user)
e.g.channelsreturns all channels connecting to this session and user providing nil as theacting_userwill test if connections can be made without there being a logged in user. -
Can a specific class connection be made:
can_connect?(channel, user = acting_user)e.g.can_connect? Todoreturns true if current acting_user can connect to the Todo class. You can also provide the class name as a string. -
Can a specific instance connection be made:
can_connect?(channel, user = acting_user)e.g.can_connect? Todo.firstreturns true if current acting_user can connect to the first Todo model. You can also provide the instance in the form 'Todo-123' -
What attributes are accessible for a model instance:
viewable_attributes(instance, user = acting_user) -
Can the attribute be viewed:
view_permitted?(instance, attribute, user = acting_user) -
Can a model be created/updated/destroyed:
create_permitted?(instance, user = acting_user)e.g.create_permitted?(Todo.new, nil)can anybody save a new todo? e.g.destroy_permitted?(Todo.last)can the acting_user destroy the last Todo
You can of course simulate server side changes to your models through this console like any other console. For example Todo.new.save will broadcast the changes to the Todo model to any authorized channels.