# It might be ORM problem

**URL:** <https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755>\
**Category:** rubyonrails-talk\
**Created:** [July 12, 2008, 9:26am UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755 "2008-07-12T09:26:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 12, 2008, 9:26am UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/1 "2008-07-12T09:26:15Z")

</div>

Hi, &nbsp;&nbsp;&nbsp;I have a model user.rb, a controller userdata\_controller, methods in the controller and respective .rhtml files. I created a registration page. Saved into users table and it works fine. But sometimes its throwing error as

undefined method `city=' for #\<User \>

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/ attribute\_methods.rb:251:in `method_missing' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:2361:in `send' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/ base.rb:2361:in `attributes=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:2360:in `each' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/ base.rb:2360:in `attributes=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:2130:in `initialize' app/controllers/matrimony\_controller.rb:124:in `new' app/controllers/matrimony_controller.rb:124:in `useraccount' -e:2:in `load' -e:2

It assumes that there is no field 'city' in table users. I confused a lot. It is never working until i restart my mongrel. I am not able to predict, when the problem rises.

Any idea? Help me..

Thanks, -Sadeesh kumar.

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 12, 2008, 12:27pm UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/2 "2008-07-12T12:27:26Z")

</div>

Hi Matthew,

> Does the `users` table have a `city` column?

Yes, &nbsp;&nbsp;My table have 'city' column. and i am able to save user data, when he do registration.This problem occurs on only at particular scenario.Just now I found a scenario, Which is

1.When i try to go to (action)registration page by clicking the link, then the registration process works well. 2.When i try to go to same (action)registration page by redirecting from another action(based on condition whether the user has logged in or not), then the registration process fails when i do save the user.

> What does the User model look like?

user.rb

---

<div class="post-metadata">

**Author:** ![Andrew\_Roth](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/andrew_roth/32/11579_2.png) [@Andrew\_Roth](https://discuss.rubyonrails.org/u/Andrew_Roth)\
**Post date:** [July 12, 2008, 2:38pm UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/3 "2008-07-12T14:38:27Z")

</div>

Do you see anything in the log file when it gives undefined method that might give a clue?

What deployment system are you using? Try running webrick and test there, if the problem doesn't happen, then it's probably something with your production deployment.

---

<div class="post-metadata">

**Author:** ![Andrew\_Roth](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/andrew_roth/32/11579_2.png) [@Andrew\_Roth](https://discuss.rubyonrails.org/u/Andrew_Roth)\
**Post date:** [July 12, 2008, 2:46pm UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/4 "2008-07-12T14:46:17Z")

</div>

> 1.When i try to go to (action)registration page by clicking the link, then the registration process works well. 2.When i try to go to same (action)registration page by redirecting from another action(based on condition whether the user has logged in or not), then the registration process fails when i do save the user.

Hmm, that's strange. The only thing I can think of is that the redirection is setting a session variable or cookie or some other persistent data that's messing up the process.

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 12, 2008, 2:55pm UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/5 "2008-07-12T14:55:47Z")

</div>

No roth, &nbsp;&nbsp;&nbsp;&nbsp;Problem comes with webrick also. And i am in development mode only. I could found the below one in my log file,

NoMethodError (undefined method `city=' for #\<User \>): &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active_record/attribute_methods.rb:251:in `method\_missing' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active\_record/base.rb:2361:in `send' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active_record/base.rb:2361:in `attributes=' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active\_record/base.rb:2360:in `each' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active_record/base.rb:2360:in `attributes=' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active\_record/base.rb:2130:in `initialize' &nbsp;&nbsp;&nbsp;&nbsp;/app/controllers/matrimony_controller.rb:124:in `new' &nbsp;&nbsp;&nbsp;&nbsp;/app/controllers/matrimony\_controller.rb:124:in `useraccount' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:1162:in `send' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/base.rb:1162:in `perform_action_without_filters' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:580:in `call\_filters' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/filters.rb:573:in `perform_action_without_benchmark' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/benchmarking.rb:68:in `perform\_action\_without\_rescue' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/benchmarking.rb:68:in `perform\_action\_without\_rescue' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/rescue.rb:201:in `perform_action_without_caching' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/caching/sql_cache.rb:13:in `perform\_action' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active\_record/connection\_adapters/abstract/query\_cache.rb:33:in `cache' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/ active_record/query_cache.rb:8:in `cache' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/caching/sql\_cache.rb:12:in `perform_action' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:529:in `send' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/base.rb:529:in `process_without_filters' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/filters.rb:569:in `process\_without\_session\_management\_support' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/session\_management.rb:130:in `process' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/base.rb:389:in `process' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/dispatcher.rb:149:in `handle_request' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:107:in `dispatch' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/dispatcher.rb:104:in `synchronize' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:104:in `dispatch' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/dispatcher.rb:120:in `dispatch_cgi' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/dispatcher.rb:35:in `dispatch' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick\_server.rb: 112:in `handle_dispatch' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb: 78:in `service' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick\_server.rb: 62:in `dispatch' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/ webrick.rb:66 &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem\_original\_require' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in `require' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ active_support/dependencies.rb:509:in `require' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ active\_support/dependencies.rb:354:in `new_constants_in' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/ active_support/dependencies.rb:509:in `require' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb: 39 &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in `gem_original_require' &nbsp;&nbsp;&nbsp;&nbsp;c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' &nbsp;&nbsp;&nbsp;&nbsp;./script/server:3 &nbsp;&nbsp;&nbsp;&nbsp;-e:2:in `load' &nbsp;&nbsp;&nbsp;&nbsp;-e:2

Rendering c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action\_controller/templates/rescues/layout.erb (internal\_server\_error)

my scenarios are this, 1.When i try to go to (action)registration page by clicking the link, then the registration process works well. 2.When i try to go to same (action)registration page by redirecting from another action(based on condition whether the user has logged in or not), then the registration process fails when i do save the user.

&nbsp;&nbsp;&nbsp;If i follow the first scenario, no problem. &nbsp;&nbsp;&nbsp;If i follow the second scenario, problem rises. &nbsp;&nbsp;&nbsp;If i follow the first scenario after did the second scenario, problem rises still.

Looking for your billion dollar answer. Thanks, -Sadeesh

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 12, 2008, 2:58pm UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/6 "2008-07-12T14:58:35Z")

</div>

my scenarios are this, 1.When i try to go to (action)registration page by clicking the link, then the registration process works well. 2.When i try to go to same (action)registration page by redirecting from another action(based on condition whether the user has logged in or not), then the registration process fails when i do save the user.

&nbsp;&nbsp;&nbsp;start the server and If i follow the first scenario, no problem. &nbsp;&nbsp;&nbsp;restart the server and If i follow the second scenario, problem rises. &nbsp;&nbsp;&nbsp;restart the server and If i follow the first scenario after did the second scenario, problem rises still.

Looking for your billion dollar answer. Thanks, -Sadeesh

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [July 12, 2008, 6:57pm UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/7 "2008-07-12T18:57:42Z")

</div>

> my scenarios are this, 1.When i try to go to (action)registration page by clicking the link, then the registration process works well. 2.When i try to go to same (action)registration page by redirecting from another action(based on condition whether the user has logged in or not), then the registration process fails when i do save the user.

Does it go away if you change cache\_classes to true in development.rb?

Fred

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 14, 2008, 5:57am UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/8 "2008-07-14T05:57:37Z")

</div>

Hi Frederick, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;First of all thanks for your reply.Your answer is great and it resolved my problem partially for the below one. -----8\<-------

> my scenarios are this, 1.When i try to go to (action)registration page by clicking the link, then the registration process works well. 2.When i try to go to same (action)registration page by redirecting from another action(based on condition whether the user has logged in or not), then the registration process fails when i do save the user.

Does it go away if you change cache\_classes to true in development.rb? Fred

------\>8--------

Yes, it gets away after I made cache\_classes = true in development.rb. But it has been fixed partially. Now what is the real problem is,

1.If I follow the first scenario as usual no problem and if I continue the second scenario, it works(because of your suggestion). 2.If I directly do the second scenario, problem rises and If I continue the first one then also problem rises. I could able to do nothing then after.

Can you explain me why? looking for your reply Frederick,

Thanks, -Sadeesh kumar.

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [July 14, 2008, 7:17am UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/9 "2008-07-14T07:17:22Z")

</div>

> Yes, it gets away after I made cache\_classes = true in development.rb. But it has been fixed partially. Now what is the real problem is,
> 
> 1.If I follow the first scenario as usual no problem and if I continue the second scenario, it works(because of your suggestion). 2.If I directly do the second scenario, problem rises and If I continue the first one then also problem rises. I could able to do nothing then after.

This means you are confusing the dependencies mechanism. This usually means that either: - You have got plugins hanging on to references to one of your model classes or instances of it - You're explicitly requiring a class (ie using require), which sidesteps rails' dependency stuff.

Fred

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 14, 2008, 8:42am UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/10 "2008-07-14T08:42:32Z")

</div>

Fred, &nbsp;&nbsp;&nbsp;&nbsp;I am using only one plugin simple\_captcha. And I never explicitly requiring a class in my app. &nbsp;&nbsp;&nbsp;Now I am in new problem which is I am having model profile.rb and table named profiles. If I tend to do like below,

&nbsp;&nbsp;&nbsp;current\_profile = Profile.new("from\_user\_id" =\> session[:user\_id],"to\_user\_id" =\> 5) &nbsp;&nbsp;&nbsp;current\_profile.save

&nbsp;&nbsp;&nbsp;then it throws similar problem, &nbsp;&nbsp;&nbsp;&nbsp;NoMethodError in MatrimonyController#forwardprofiles

undefined method `to\_user\_id=' for #\<Profile \>

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/ attribute\_methods.rb:251:in `method_missing' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:2361:in `send' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/ base.rb:2361:in `attributes=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:2360:in `each' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/ base.rb:2360:in `attributes=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/ base.rb:2130:in `initialize' app/controllers/matrimony\_controller.rb:52:in `new' app/controllers/matrimony_controller.rb:52:in `forwardprofiles' app/controllers/matrimony\_controller.rb:49:in `each' app/controllers/matrimony_controller.rb:49:in `forwardprofiles' -e:2:in `load' -e:2

By comparing this with the previous one, do you have any Idea?

Thanks, -Sadeesh.

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [July 14, 2008, 11:15am UTC](https://discuss.rubyonrails.org/t/it-might-be-orm-problem/31755/11 "2008-07-14T11:15:11Z")

</div>

k Matthew, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I do the same. Thanks, -Sadeesh.
