We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruby Version: 3.1.3
Framework Version (Rails, whatever): 7.0.4.2
Action Policy Version: latest
Reproduction Script: n/a
i am using I18n active record but this doesnt seem to fly with the I18n support built into action_policy.
it should use a translation key thats actually stored in the db: action_policy.policy.session.create?
action_policy.policy.session.create?
it used the default key: action_policy.unauthorized
action_policy.unauthorized
my application_controller looks like this:
rescue_from ActionPolicy::Unauthorized do |e| message = { message: e.result.message, show: true, type: 'error' } render json: { message: message }, status: :forbidden end
i have a SessionPolicy
SessionPolicy
class SessionPolicy < ApplicationPolicy authorize :user def create? false end def destroy? true end end
which is called by this in my SessionsController:
def create message = { message: I18n.t('session.create.unsuccessful'), show: true, type: 'error' } user = User.authenticate(session_params[:email], session_params[:password]) authorize! user, with: SessionPolicy, context: { user: user } <snip> end
maybe i do something wrong?
The text was updated successfully, but these errors were encountered:
We have no assumptions on I18n backend, we simply call I18n.t:
I18n.t
action_policy/lib/action_policy/i18n.rb
Line 14 in 04a5790
Can you please provide the value of the e.result.all_details? Also, e.result.rule and e.result.policy.identifier
e.result.all_details
e.result.rule
e.result.policy.identifier
Sorry, something went wrong.
No branches or pull requests
Tell us about your environment
Ruby Version: 3.1.3
Framework Version (Rails, whatever): 7.0.4.2
Action Policy Version: latest
Reproduction Script: n/a
What did you do?
i am using I18n active record but this doesnt seem to fly with the I18n support built into action_policy.
What did you expect to happen?
it should use a translation key thats actually stored in the db:
action_policy.policy.session.create?
What actually happened?
it used the default key:
action_policy.unauthorized
my application_controller looks like this:
i have a
SessionPolicy
which is called by this in my SessionsController:
maybe i do something wrong?
The text was updated successfully, but these errors were encountered: