2018-01-29 22:19:10 +00:00
|
|
|
# Forma de ingreso a Sutty
|
2018-01-02 17:19:25 +00:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
protect_from_forgery with: :exception
|
2018-01-29 18:09:30 +00:00
|
|
|
|
2018-01-29 22:19:10 +00:00
|
|
|
# No tenemos índice de sutty, vamos directamente a ver el listado de
|
|
|
|
# sitios
|
2018-01-29 18:09:30 +00:00
|
|
|
def index
|
|
|
|
redirect_to sites_path
|
|
|
|
end
|
2018-01-29 22:19:10 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Encontrar un sitio por su ID
|
|
|
|
# TODO volverlo más natural a rails
|
|
|
|
def find_site
|
|
|
|
id = params[:site_id] || params[:id]
|
|
|
|
|
|
|
|
current_user.sites.find do |s|
|
|
|
|
s.id == id
|
|
|
|
end
|
|
|
|
end
|
2018-01-30 15:20:19 +00:00
|
|
|
|
|
|
|
def find_post(site)
|
|
|
|
id = params[:post_id] || params[:id]
|
|
|
|
|
|
|
|
site.posts.find do |p|
|
|
|
|
p.id == id
|
|
|
|
end
|
|
|
|
end
|
2018-01-02 17:19:25 +00:00
|
|
|
end
|