Skip to content

Commit

Permalink
Use ActiveModel::Naming to get crud model names. Much more reliable.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Nov 9, 2011
1 parent f80e9ff commit 25162b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/lib/refinery/crud.rb
Expand Up @@ -18,15 +18,14 @@ module Refinery
module Crud

def self.default_options(model_name)
singular_name = model_name.to_s.split('/').last
class_name = "::#{model_name.to_s.camelize.gsub('/', '::')}".gsub('::::', '::')
plural_name = singular_name.to_s.gsub('/', '_').pluralize
this_class = class_name.constantize.base_class

singular_name = ActiveModel::Naming.param_key(this_class)
plural_name = singular_name.pluralize
{
:conditions => '',
:include => [],
:order => ('position ASC' if this_class.table_exists? and this_class.column_names.include?('position')),
:order => ('position ASC' if this_class.table_exists? && this_class.column_names.include?('position')),
:paging => true,
:per_page => false,
:redirect_to_url => "main_app.refinery_admin_#{plural_name}_path",
Expand Down

0 comments on commit 25162b5

Please sign in to comment.