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:
parent
83762bd0e6
commit
aa9806d8f6
2 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue