Skip to content

Instantly share code, notes, and snippets.

@fernandomm
Created July 1, 2014 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandomm/639c1ce87b866055c209 to your computer and use it in GitHub Desktop.
Save fernandomm/639c1ce87b866055c209 to your computer and use it in GitHub Desktop.
def show
@post = current_user.posts.find_by_id params[:id]
unless @post
redirect_to posts_path, :alert => 'Post not found'
end
end
@augustoppimenta
Copy link

Olá Fernando,

Consegui fazer como você me orientou. Meu código ficou assim:

def show
  @post = current_manager.post.find(params[:id])
  unless @post
   flash[:error] = 'Você não permissão para acessar essa página'
   redirect_to manager_root_path
  end
add_breadcrumb "Post ##{@post.id}", request.url
end

O problemas está resolvido. Brigadão pela ajuda! Mas apenas que o Alert/Flash não está funcionando nem em produção nem em desenvolvimento. Teria alguma dica?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment