Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

generator should add meaningful error in hypermesh policy file: #5

@catmando

Description

@catmando

currently generator creates this policy file:

# 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 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 }
end if Rails.env.development?

The problem is that when moving to production (or test) its not clear why you are suddenly getting 500 errors. We on purpose do not give any additional information when raising these errors (to avoid giving any details of what is going on to potential hackers.)

So the solution might be this:

# 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.

# This policy will open up everything in development, and otherwise raise an 
# error.  This is intended to just get you started.  Normally you will want to run 
# the same policies in development, test and production, so once you have
# defined a proper set of policies you no longer need to check which 
# environment you are in.

class ApplicationPolicy
  if Rails.env.development? 
    # 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 }
  else
    raise "No policies defined - review and update 'app/policies/application_policy.rb'"
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions