forked from staszek/easycrumbs
/
helper.rb
69 lines (53 loc) · 1.3 KB
/
helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'test/unit'
require 'shoulda'
require "mocha"
require 'active_record'
require "action_controller"
require "routes"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'easycrumbs'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Base.configurations = true
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define(:version => 1) do
create_table :countries do |t|
t.string :name
t.string :breadcrumb
end
create_table :movies do |t|
t.string :name
t.integer :country_id
end
create_table :actors do |t|
t.string :first_name
t.string :last_name
t.integer :movie_id
end
end
# =========== Rails Classes and Objects ===========
include EasyCrumbs
class Country < ActiveRecord::Base
has_many :movies
end
class Movie < ActiveRecord::Base
has_many :actors
belongs_to :country
end
class Actor < ActiveRecord::Base
belongs_to :movie
def breadcrumb
"#{first_name} #{last_name}"
end
end
class ApplicationController < ActionController::Base
end
class CountriesController < ApplicationController
def breadcrumb
"Countries list"
end
end
class MoviesController < ApplicationController
end
class ActorsController < ApplicationController
end