Warning: toplevel constant Configuration referenced by ActiveRecord::Base::Configuration

Hi,

I am facing the error msg mention in subject, and my theme doesn’t
change.

*** init.rb ********
require File.join(File.dirname(FILE), “lib”, “fedena_theme”)
FedenaPlugin.register = {
:name=>“fedena_theme”,
:description=>“Fedena Theme”
}

******* /// the line 52 in init.rb showing error /////////////****
52. current_theme =
ActiveRecord::Base::Configuration.get_config_value “Color”

*****fedena_theme.rb **********

TestPlugin

require ‘action_view/helpers/asset_tag_helper’

class FedenaTheme
COLORS = {1 => {:color => “#701288”,:accent_color =>
#4e0d5f”,:border_color => “#8d41a0”,:sort_order => 16},
2 => {:color => “#39a6ef”,:accent_color =>
#2874a7”,:border_color => “#61b8f2”,:sort_order => 24},
3 => {:color => “#006290”,:accent_color =>
#004465”,:border_color => “#3381a6”,:sort_order => 26}
}
FONTS ={1 =>{:text => “Arial”, :value => “Arial”},2 =>{:text =>
“Verdana”, :value => “Verdana, Arial”},3 =>{:text => “Comic Sans MS”,
:value => “Comic Sans MS, Arial”},4 =>{:text => “Georgia”, :value =>
“Georgia, Times new Roman”},5 => {:text => “Times new Roman”, :value =>
“Times new Roman”},6 => {:text => “Trebuchet MS”, :value => “Trebuchet
MS, Arial”},7 => {:text => “Garamond”, :value => “Garamond, Times new
Roman”}}
unloadable

def self.general_settings_form
“configuration/theme_select”
end

def self.available_themes
directory = “#{Rails.public_path}/themes”
themes = Dir.entries(directory).select {|entry| File.directory?
File.join(directory,entry) and !(entry ==’.’ ||
entry == ‘…’) }
return [[‘Default’, ‘default’]]+themes.collect { |theme|
[theme.titleize, theme] }
end

def self.selected_theme
Configuration.get_config_value(“Color”)
end

def self.selected_color_value
val = selected_theme
COLORS[val.to_i][:color]
end

end

********* Errors showing
/vendor/plugins/fedena_theme/init.rb:52: warning: toplevel
constant Configuration referenced by ActiveRecord::Base::Configuration

Please help, I dont understand the error and how to resolve this. I
upgraded my App from Rails 2.3.5 to 2.3.10

The simplest way to trigger this warning (it’s not Rails-related BTW) is
this:

$ irb
irb(main):001:0> class Foo
irb(main):002:1> end
=> nil
irb(main):003:0> Foo::Array.new
(irb):3: warning: toplevel constant Array referenced by Foo::Array
=> []

So it seems that in addition to ActiveRecord::Base:Configuration
there’s
another class called Configuration defined at the top level.

Did you define this class? If not, does any of your dependencies define
this class?

Best regards

Greg Navis
I help small tech companies to scale Heroku-hosted Rails apps.
Free, biweekly scalability newsletter for SaaS CEOs
http://www.gregnavis.com/newsletter/

Greg Navis wrote in post #1183062:

The simplest way to trigger this warning (it’s not Rails-related BTW) is
this:

$ irb
irb(main):001:0> class Foo
irb(main):002:1> end
=> nil
irb(main):003:0> Foo::Array.new
(irb):3: warning: toplevel constant Array referenced by Foo::Array
=> []

So it seems that in addition to ActiveRecord::Base:Configuration
there’s
another class called Configuration defined at the top level.

Did you define this class? If not, does any of your dependencies define
this class?

As I told before in Rails 2.3.5 it was working fine, even though was
showing this warning as well but even then I could change the theme, but
in 2.3.10 its not changing the theme.

The themes plugin code is here:
https://www.dropbox.com/s/hvgej1nbmqdinlw/fedena_theme.zip?dl=0

On 25 April 2016 at 16:08, Naveed A. [email protected] wrote:

=> []
in 2.3.10 its not changing the theme.
That does not answer the question.

If you search your code for Configuration does it find anything?

Colin

Colin L. wrote in post #1183067:

On 25 April 2016 at 16:08, Naveed A. [email protected] wrote:

=> []
in 2.3.10 its not changing the theme.
That does not answer the question.

If you search your code for Configuration does it find anything?

Colin

Yes I have a Configuration Model/Controler below are the links to
controller, and model

https://www.dropbox.com/s/4znjursig0oz7af/configuration_controller.rb?dl=0

https://www.dropbox.com/s/sy6o9c3o4xskj15/configuration.rb?dl=0

Colin L. wrote in post #1183079:

On 26 April 2016 at 05:10, Naveed A. [email protected] wrote:

Yes I have a Configuration Model/Controler below are the links to
controller, and model

In that case your simplest solution may be to change the name of the
model.

Colin

If I change the model name, then I have to make a lot of changes in
many other Controllers and where its been called
and the migration too.
so I get a lot of error messages.

Can u get any idea from the below tree diagram that if there any change
possible can make it resolve the problem. I changed the configration
folded name in fedena_theme app views but didnt do anything

The Configration model’s file tree is
App
|-Views
|_Configuration.rb

And this plugin fedena themes files tree is

App -Vendor - Plugins- fedena_theme
:
:_ views
:_Configuration
: _theme_select.html
:_themes

On 26 April 2016 at 05:10, Naveed A. [email protected] wrote:

Yes I have a Configuration Model/Controler below are the links to
controller, and model

In that case your simplest solution may be to change the name of the
model.

Colin

On 26 April 2016 at 13:13, Naveed A. [email protected] wrote:

If I change the model name, then I have to make a lot of changes in
many other Controllers and where its been called
and the migration too.
so I get a lot of error messages.

A few global search and replace changes should do it. You don’t need
to change the controller or table name if you don’t want to. I assume
you have the source under a source control system such as git, and
that you have good automated test coverage, which will make sure you
catch everything.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs