Skip to content

Instantly share code, notes, and snippets.

class Application
before :back_navigation
# maintain a back trace stack in session[:page_history], removing
# any path loops. back_resource() in global_helper will then
# use session[:page_history].
def back_navigation
session[:page_history] ||= []
previous_page = request.env['HTTP_REFERER'].to_s
current_page = (request.env['rack.url_scheme'] +
irb(main):003:0> a = Account.first
~ SELECT `id`, `register_number`, `created_at`, `updated_at` FROM `accounts` ORDER BY `id` LIMIT 1
=> #<Account id=1 register_number=nil created_at=nil updated_at=nil>
irb(main):004:0> c = Contact.first
~ SELECT `id`, `title`, `first_name`, `middle_name`, `last_name`, `suffix`, `company_name`, `created_at`, `updated_at`, `account_id`, `veterinarian_id`, `groomer_id`, `clinic_id` FROM `contacts` ORDER BY `id` LIMIT 1
=> #<Contact id=1 title=nil first_name=nil middle_name=nil last_name=nil suffix=nil company_name=nil created_at=nil updated_at=#<DateTime: 212096641211/86400,-1/4,2299161> account_id=1 veterinarian_id=nil groomer_id=nil clinic_id=nil>
irb(main):005:0> c.account = a
=> #<Account id=1 register_number=nil created_at=nil updated_at=nil>
irb(main):006:0> c.save
=> true