diff --git a/README.md b/README.md index b4b8dd8ba..25dff3904 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,28 @@ and migrate your database. To create the first user, start the application server, go to http://0.0.0.0:3000/admin and follow the instructions. +## Namespaced Models? + +If you want to be able to use `delayed_job` you need to add the following +two lines to your `config/routes.rb` file. + + map.connect "admin/delayed/jobs/:action/:id", :controller => "admin/delayed/jobs" + map.connect "admin/delayed/jobs/:action/:id.:format", :controller => "admin/delayed/jobs" + +And then create and configure `config/typus/delayed_job.yml` and +`config/typus/delayed_job_roles.yml` as you do with your other models. + + # config/typus/delayed_job.yml + Delayed::Job: + fields: + list: ... + form: ... + search: ... + + # config/typus/delayed_job_roles.yml + admin: + Delayed::Job: all + ## Support As an experiment we encourage you to support this project by diff --git a/app/helpers/typus_helper.rb b/app/helpers/typus_helper.rb index 9eeb9e70e..9657d7bb9 100644 --- a/app/helpers/typus_helper.rb +++ b/app/helpers/typus_helper.rb @@ -86,7 +86,7 @@ def header def login_info(user = @current_user) - admin_edit_typus_user_path = { :controller => "admin/#{Typus::Configuration.options[:user_class_name].tableize}", + admin_edit_typus_user_path = { :controller => "/admin/#{Typus::Configuration.options[:user_class_name].tableize}", :action => 'edit', :id => user.id } diff --git a/config/routes.rb b/config/typus_routes.rb similarity index 100% rename from config/routes.rb rename to config/typus_routes.rb diff --git a/lib/extensions/routes.rb b/lib/extensions/routes.rb new file mode 100644 index 000000000..9849331fe --- /dev/null +++ b/lib/extensions/routes.rb @@ -0,0 +1,13 @@ +class ActionController::Routing::RouteSet + + def load_routes_with_typus! + typus_routes = File.join(File.dirname(__FILE__), *%w[.. .. config typus_routes.rb]) + unless configuration_files.include? typus_routes + add_configuration_file(typus_routes) + end + load_routes_without_typus! + end + + alias_method_chain :load_routes!, :typus + +end diff --git a/lib/typus.rb b/lib/typus.rb index 55beadb80..11beda34c 100644 --- a/lib/typus.rb +++ b/lib/typus.rb @@ -98,6 +98,7 @@ def boot! require "extensions/object" require "extensions/string" require "extensions/active_record" + require "extensions/routes" # Load configuration and roles. Typus::Configuration.config!