5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 05:01:41 +00:00

optimizacion: no preguntar si es usuarie todo el tiempo

solo funciona cuando le usuarie es usuarie del sitio.  si es invitade,
la pregunta se hace por cada post.
This commit is contained in:
f 2020-01-02 15:05:28 -03:00
parent 83762bd0e6
commit aa9806d8f6
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 4 additions and 3 deletions

View file

@ -13,6 +13,7 @@ class PostsController < ApplicationController
# TODO: Aplicar policy_scope
@posts = @site.posts(lang: I18n.locale)
@posts.sort_by!(:order, :date).reverse!
@usuarie = @site.usuarie? current_usuarie
end
def show

View file

@ -42,7 +42,7 @@
- next unless post.categories.value.include?(@category)
- if @layout
- next unless post.layout.name == @layout
- next unless policy(post).show?
- next unless @usuarie || policy(post).show?
%tr
%td
.handle
@ -73,11 +73,11 @@
%br/
= post.try(:order).try(:value)
%td
- if policy(post).edit?
- if @usuarie || policy(post).edit?
= link_to t('posts.edit'),
edit_site_post_path(@site, post.id),
class: 'btn'
- if policy(post).destroy?
- if @usuarie || policy(post).destroy?
= link_to t('posts.destroy'),
site_post_path(@site, post.id),
class: 'btn',