46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/generators/hyperloop/install_generator.rb', line 46
def create_policies_directory
create_file 'app/policies/application_policy.rb', <<-RUBY
# app/policies/application_policy
# Policies regulate access to your public models
# The following policy will open up full access (but only in development)
# The policy system is very flexible and powerful. See the documentation
# for complete details.
class Hyperloop::ApplicationPolicy
# Allow any session to connect:
always_allow_connection
# Send all attributes from all public models
regulate_all_broadcasts { |policy| policy.send_all }
# Allow all changes to public models
allow_change(to: :all, on: [:create, :update, :destroy]) { true }
# allow remote access to all scopes - i.e. you can count or get a list of ids
# for any scope or relationship
ApplicationRecord.regulate_scope :all
end unless Rails.env.production?
RUBY
end
|