NameError in AdminController#list_raw_data

i need some help to fix this problem

i have a model named rawdata.rb pointing to a table class Rawdata < ActiveRecord::Base     set_table_name "rawdatas"

i have setup my controller file named admin_controller.rb with the following function. def list_raw_data   sql="select * from rawdatas order by tradedatetime desc"      @rawdata_pages, @rawdata = paginate :rawdata, :per_page => 50

  end

when i try to launch http://localhost:3000/admin/list_raw_data/

i get error NameError in AdminController#list_raw_data uninitialized constant Rawdatum RAILS_ROOT: ./script/../config/..

Application Trace | Framework Trace | Full Trace e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:266:in `load_missing_constant' e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in `const_missing' e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:464:in `const_missing' e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/inflector.rb:250:in `constantize' e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/core_ext/string/inflections.rb:148:in `constantize' e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/pagination.rb:201:in `paginator_and_collection_for' e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/pagination.rb:132:in `paginate_without_deprecation' e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/deprecation.rb:94:in `paginate' E:/TradingTools/Development/app/controllers/admin_controller.rb:28:in `list_raw_data'

i need some help to fix this problem

i have a model named rawdata.rb pointing to a table class Rawdata < ActiveRecord::Base    set_table_name "rawdatas"

i have setup my controller file named admin_controller.rb with the
following function. def list_raw_data sql="select * from rawdatas order by tradedatetime desc"

I assume you know that this does nothing.

    @rawdata_pages, @rawdata = paginate :rawdata, :per_page => 50

end

when i try to launch http://localhost:3000/admin/list_raw_data/

It's assuming that rawdata is the plural of rawdatum. You could fiddle
with the inflections.

Fred

I assume that the inflection is used by the model only. i had setup the model that the table name is set_table_name "rawdatas"

How can i fix the controller for the same?

i need some help to fix this problem

i have a model named rawdata.rb pointing to a table class Rawdata < ActiveRecord::Base    set_table_name "rawdatas"

i have setup my controller file named admin_controller.rb with the
following function. def list_raw_data sql="select * from rawdatas order by tradedatetime desc"

I assume you know that this does nothing.

    @rawdata_pages, @rawdata = paginate :rawdata, :per_page => 50

end

when i try to launch http://localhost:3000/admin/list_raw_data/

It's assuming that rawdata is the plural of rawdatum. You could fiddle
with the inflections.

Fred

I assume that the inflection is used by the model only.

It's not.

i had setup the model that the table name is set_table_name "rawdatas"

that's a separate thing

How can i fix the controller for the same?

Depending on your version of rails you can find inflector examples
either at the bottom of environment.rb or in one of the initializers
(in config/initializers)

Fred

I assume that the inflection is used by the model only.

It's not.

i had setup the model that the table name is set_table_name "rawdatas"

that's a separate thing

How can i fix the controller for the same?

Depending on your version of rails you can find inflector examples
either at the bottom of environment.rb or in one of the initializers
(in config/initializers)

One other way would of course be to rename your model ( & the
associated file).

Fred

i found the inflections in the environment.rb and uncommneted it. i tried to monkeypatch it like the following    Inflector.inflections do |inflect|   if not(inflect=="rawdata") then      inflect.plural /^(ox)$/i, '\1en'      inflect.singular /^(ox)en/i, '\1'      inflect.irregular 'person', 'people'      inflect.uncountable %w( fish sheep )    end    end

It still does not work. i also restarted the server to see ifit will take effect but it did not. i want the controller to think that rawdata inflection is still rawdata.

Any help is appreciated.

i need some help to fix this problem

i have a model named rawdata.rb pointing to a table class Rawdata < ActiveRecord::Base     set_table_name "rawdatas"

i have setup my controller file named admin_controller.rb with the following function. def list_raw_data   sql="select * from rawdatas order by tradedatetime desc"      @rawdata_pages, @rawdata = paginate :rawdata, :per_page => 50

  end

when i try to launch http://localhost:3000/admin/list_raw_data/

i get error NameError in AdminController#list_raw_data uninitialized constant Rawdatum RAILS_ROOT: ./script/../config/..

i found the inflections in the environment.rb and uncommneted it. i
tried to monkeypatch it like the following   Inflector.inflections do |inflect|   if not(inflect=="rawdata") then     inflect.plural /^(ox)$/i, '\1en'     inflect.singular /^(ox)en/i, '\1'     inflect.irregular 'person', 'people'     inflect.uncountable %w( fish sheep )   end   end

Inflector.inflections do |inflect|    inflect.irregular 'rawdata', 'rawdatas' end

(you do need to restart the server)

I've remembered paginate expects you to pass the the plural form, so
you need paginate :rawdatas

With the inflection you can drop the set_table_name

Fred

thanks a lot so far. i have a new challenge.

my controller function is here def list_raw_data       @rawdata_pages, @rawdata = paginate :rawdatas, :per_page => 50 end

how does the controller know which view to render with the pages. the example that i am mocking does not do a render action. i am getting a entry page instead of a list page. should i add a render before the end of the function above.

junkone1 wrote: