-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zeitwerk eager-loading doesn't like gretel
Apparently Gretel uses `instance_eval` to load it's breadcrumbs up; which is why `crumb` is available on `Object`. This is kinda a hacky-way to deal with that; but it may make sense for us to exclude the breadcrumb paths from autoloading somehow?
- Loading branch information
Showing
2 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# @see https://github.com/kzkn/gretel | ||
crumb :journal_entry do |entry| | ||
parent :room, entry.room | ||
link entry.headline, [entry.space, entry.room, entry] | ||
end | ||
|
||
crumb :new_journal_entry do |entry| | ||
parent :room, entry.room | ||
link 'Add a Journal Entry', [:new, entry.space, entry.room] | ||
end | ||
begin | ||
crumb :journal_entry do |entry| | ||
parent :room, entry.room | ||
link entry.headline, [entry.space, entry.room, entry] | ||
end | ||
|
||
crumb :edit_journal_entry do |entry| | ||
parent :journal_entry, entry | ||
link "Edit", [:edit, entry.space, entry.room, entry] | ||
crumb :new_journal_entry do |entry| | ||
parent :room, entry.room | ||
link 'Add a Journal Entry', [:new, entry.space, entry.room] | ||
end | ||
|
||
crumb :edit_journal_entry do |entry| | ||
parent :journal_entry, entry | ||
link 'Edit', [:edit, entry.space, entry.room, entry] | ||
end | ||
rescue NoMethodError => e | ||
throw e unless e.message.start_with?("undefined method `crumb'") | ||
end | ||
module Journal::Breadcrumbs | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Gretel.breadcrumb_paths << Rails.root.join('app', 'furniture', '**', 'breadcrumbs.rb') | ||
Gretel.breadcrumb_paths << Rails.root.join('app', 'furniture', '**', 'breadcrumbs', '*.rb') | ||
Rails.application.config.to_prepare do | ||
Gretel.breadcrumb_paths << Rails.root.join('app', 'furniture', '**', 'breadcrumbs.rb') | ||
Gretel.breadcrumb_paths << Rails.root.join('app', 'furniture', '**', 'breadcrumbs', '*.rb') | ||
end |