> On Oct 5, 2018, at 4:17 AM, Rob Jonson wrote:
>
> again - taste and preference here.
>
> my issue with `policy_scope(User)` in the view isn't that it is complex
> code, clearly it isn't.
>
> it's more that I don't want my view to know or care about authorisation.
>
> I think when
again - taste and preference here.
my issue with `policy_scope(User)` in the view isn't that it is complex
code, clearly it isn't.
it's more that I don't want my view to know or care about authorisation.
I think when you're talking about a select 'policy_scope(User).collect',
you're asking
I agree with Rob that it is in the realm of taste and preference. I
wouldn't have something like this in my view:
users = User.where(active:
true).join(:transactions).merge(Transaction.where('total > 1000'))
form.collection_select users, :id, :name
This would be putting model level
Ok, that makes sense...
Everything is working fine the way it is coded but I am fairly new to RoR
and want to learn proper practices.
One of the things I do with pundit is to filter the data by a particular
School District, so in the "scope" of Pundit I look to see what role the
user has and
Hi John,
firstly - I don't know pundit, so this is only general advice.
secondly - we're definitely in the realm of taste and preference here
rather than 'ok' and 'not ok'
having said that, my two pence:
the rails style guide says 'Never call the model layer directly from a view'
Excellent...
So it's OK to call policy_scope(User) from a view?
That's what I was confused by...
On Wednesday, October 3, 2018 at 12:44:52 PM UTC-4, Eric Anderson wrote:
>
> There is an `collection_select` form builder that will do the `collect`
> for you. So:
>
> <%= f.collection_select
There is an `collection_select` form builder that will do the `collect` for
you. So:
<%= f.collection_select :user, policy_scope(User), :id, :name %>
If you are not using a form builder then
`options_from_collection_for_select` is useful for the same purpose.
If those helpers cannot be
7 matches
Mail list logo