# NameError in AdminController#list\_raw\_data

**URL:** <https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762>\
**Category:** Rails\
**Created:** [June 30, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762 "2008-06-30T13:37:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/1 "2008-06-30T13:37:15Z")

</div>

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/](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’

–  
View this message in context:  
[http://www.nabble.com/NameError-in-AdminController-list\_raw\_data-tp18193714p18193714.html](http://www.nabble.com/NameError-in-AdminController-list_raw_data-tp18193714p18193714.html)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/2 "2008-06-30T14:45:59Z")

</div>

On 30 Jun 2008, at 12:36, junkone1 wrote:

> 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/](http://localhost:3000/admin/list_raw_data/)

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

Fred

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/3 "2008-06-30T16:44:29Z")

</div>

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?

On 30 Jun 2008, at 12:36, junkone1 wrote:

> 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/](http://localhost:3000/admin/list_raw_data/)

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

Fred

> active\_support/dependencies.rb:452:in  
> e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/

–  
View this message in context:  
[http://www.nabble.com/NameError-in-AdminController-list\_raw\_data-tp18193714p18197223.html](http://www.nabble.com/NameError-in-AdminController-list_raw_data-tp18193714p18197223.html)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 4:48pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/4 "2008-06-30T16:48:36Z")

</div>

On 30 Jun 2008, at 15:47, Frederick C. wrote:

> > that the table name is set\_table\_name “rawdatas”

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

Fred

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 4:48pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/5 "2008-06-30T16:48:01Z")

</div>

On 30 Jun 2008, at 15:44, junkone1 wrote:

> 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

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 6:01pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/6 "2008-06-30T18:01:58Z")

</div>

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/](http://localhost:3000/admin/list_raw_data/)

## i get error NameError in AdminController#list\_raw\_data uninitialized constant Rawdatum RAILS\_ROOT: ./script/…/config/…

View this message in context:  
[http://www.nabble.com/NameError-in-AdminController-list\_raw\_data-tp18193714p18198801.html](http://www.nabble.com/NameError-in-AdminController-list_raw_data-tp18193714p18198801.html)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 6:28pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/7 "2008-06-30T18:28:54Z")

</div>

On 30 Jun 2008, at 17:01, junkone1 wrote:

> ```
> 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

---

<div class="post-metadata">

**Author:** ![junkone1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@junkone1](https://www.ruby-forum.com/u/junkone1)\
**Post date:** [June 30, 2008, 7:32pm UTC](https://www.ruby-forum.com/t/nameerror-in-admincontroller-list-raw-data/141762/8 "2008-06-30T19:32:53Z")

</div>

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:

> following function.  
> uninitialized constant Rawdatum  
> `constantize’

–  
View this message in context:  
[http://www.nabble.com/NameError-in-AdminController-list\_raw\_data-tp18193714p18200441.html](http://www.nabble.com/NameError-in-AdminController-list_raw_data-tp18193714p18200441.html)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).
