Skip to content

Commit

Permalink
Draw admin route and fix rich text field
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Mar 4, 2024
1 parent aa92381 commit ef149e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/administrate/base_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require "administrate/field/polymorphic"
require "administrate/field/select"
require "administrate/field/string"
require "administrate/field/rich_text"
require "administrate/field/text"
require "administrate/field/time"
require "administrate/field/url"
Expand Down
16 changes: 16 additions & 0 deletions lib/generators/administrate/dashboard/dashboard_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ def create_resource_controller
template("controller.rb.erb", destination)
end

def admin_route
return unless options[:routes]

["config/routes/admin.rb", "config/routes.rb"].each do |path|
full_path = Rails.root.join(path)
routes = full_path if File.exists?(full_path)
end
return if routes.nil?

content = "resources :#{file_name.pluralize}\n"
sentinel = /namespace :#{namespace}.*\n/
indent = File.binread(routes)[/\n(\s*)namespace :#{namespace}/, 1] || ""

inject_into_file routes, indent + " " + content, after: sentinel
end

private

def namespace
Expand Down

0 comments on commit ef149e1

Please sign in to comment.