Skip to content

Instantly share code, notes, and snippets.

@milushov
Created December 21, 2012 15:18
Show Gist options
  • Save milushov/4353416 to your computer and use it in GitHub Desktop.
Save milushov/4353416 to your computer and use it in GitHub Desktop.
# encoding: utf-8
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_temp_attachable_id, :prepare
private
def prepare
@categories = Category.all
@team = User.public.limit(4)
@special_objects = RealtyObject.special.limit(12)
@layout_options = {
header_fixed: false,
header_menu: true
}
@temp_attachable_id = session[:temp_attachments][:attachable_id]
end
def set_temp_attachable_id
if request.env['REQUEST_METHOD'] == 'GET'
session[:temp_attachments] = {
attachable_id: rand(-2_000_000..-1_000_000),
attachments_ids: []
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment