Entry not updated in database table(Active Record Error)

Hello All,

I have a table invitation_workflows.Entry to this table is done via
method send_invite which is called on the click of an Invite button.
When I click on Invite button for the first time,entry gets created in
the invitation_workflows table.
However on subsequent clicks,the following error is shown


INTERNAL ERROR:Thu Mar 17 17:28:45 +0530 2011 ----------
Client Ip : 127.0.0.1
User Id : 101346
Exception : ActiveRecord::ActiveRecordError: ERROR: column “id” does
not exist
Position: 322: INSERT INTO
“invitation_workflows” (“invitation_workflow_id”, “invitor_id”,
“invited_whom_id”, “invited_for_channel_id”, “invite_status”,
“created_by”, “updated_by”, “created_at”, “updated_at”) VALUES(NULL,
5088, NULL, 21218, ‘P’, ‘101346’, ‘101346’, ‘2011-03-17
11:58:45.553000’, ‘2011-03-17 11:58:45.553000’) RETURNING “id”
C:/Microblogging_release1.3/vendor/rails/activerecord/lib/
active_record/connection_adapters/abstract_adapter.rb:219:in log'c:/ jruby-1.5.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.7- java/lib/active_record/connection_adapters/jdbc_adapter.rb:655:inselect’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-
adapter-0.9.7-java/lib/active_record/connection_adapters/
jdbc_adapter.rb:578:in select_one'C:/Microblogging_release1.3/vendor/ rails/activerecord/lib/active_record/connection_adapters/abstract/ database_statements.rb:19:inselect_value’c:/jruby-1.5.0/lib/ruby/
gems/1.8/gems/activerecord-jdbc-adapter-0.9.7-java/lib/jdbc_adapter/
jdbc_postgre.rb:252:in insert'C:/Microblogging_release1.3/vendor/ rails/activerecord/lib/active_record/base.rb:2908:increate’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
timestamp.rb:53:in create_with_timestamps'C:/Microblogging_release1.3/ vendor/rails/activerecord/lib/active_record/callbacks.rb:266:increate_with_callbacks’C:/Microblogging_release1.3/vendor/rails/
activerecord/lib/active_record/base.rb:2874:in create_or_update'C:/ Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/ callbacks.rb:250:increate_or_update_with_callbacks’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
base.rb:2538:in save'C:/Microblogging_release1.3/vendor/rails/ activerecord/lib/active_record/validations.rb:1078:insave_with_validation’C:/Microblogging_release1.3/vendor/rails/
activerecord/lib/active_record/dirty.rb:79:in save_with_dirty'C:/ Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/ transactions.rb:229:inwith_transaction_returning_status’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/database_statements.rb:136:in
transaction'C:/Microblogging_release1.3/vendor/rails/activerecord/lib/ active_record/transactions.rb:182:intransaction’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
transactions.rb:228:in with_transaction_returning_status'C:/ Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/ transactions.rb:196:insave_with_transactions’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
transactions.rb:208:in rollback_active_record_state!'C:/ Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/ transactions.rb:196:insave_with_transactions’C:/
Microblogging_release1.3/app/controllers/
invitation_workflows_controller.rb:14:in send_invite'C:/ Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/ base.rb:1331:inperform_action’C:/Microblogging_release1.3/vendor/
rails/actionpack/lib/action_controller/filters.rb:617:in
call_filters'C:/Microblogging_release1.3/vendor/rails/actionpack/lib/ action_controller/filters.rb:610:inperform_action_with_filters’C:/
Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:68:in perform_action_with_benchmark'C:/ Microblogging_release1.3/vendor/rails/activesupport/lib/active_support/ core_ext/benchmark.rb:17:inms’c:/jruby-1.5.0/lib/ruby/1.8/
benchmark.rb:308:in realtime'C:/Microblogging_release1.3/vendor/rails/ activesupport/lib/active_support/core_ext/benchmark.rb:17:inms’C:/
Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:68:in perform_action_with_benchmark'C:/ Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/ rescue.rb:160:inperform_action_with_rescue’C:/
Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/
flash.rb:146:in perform_action_with_flash'C:/Microblogging_release1.3/ vendor/rails/actionpack/lib/action_controller/base.rb:532:inprocess’C:/Microblogging_release1.3/vendor/rails/actionpack/lib/
action_controller/filters.rb:606:in process_with_filters'C:/ Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/ base.rb:391:inprocess’C:/Microblogging_release1.3/vendor/rails/
actionpack/lib/action_controller/base.rb:386:in call'C:/ Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/ routing/route_set.rb:437:incall’C:/Microblogging_release1.3/vendor/
rails/actionpack/lib/action_controller/dispatcher.rb:87:in
dispatch'C:/Microblogging_release1.3/vendor/rails/actionpack/lib/ action_controller/dispatcher.rb:121:in_call’C:/
Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/
dispatcher.rb:130:in build_middleware_stack'C:/ Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/ query_cache.rb:29:incall’C:/Microblogging_release1.3/vendor/rails/
activerecord/lib/active_record/query_cache.rb:29:in call'C:/ Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/ connection_adapters/abstract/query_cache.rb:34:incache’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
query_cache.rb:9:in cache'C:/Microblogging_release1.3/vendor/rails/ activerecord/lib/active_record/query_cache.rb:28:incall’C:/
Microblogging_release1.3/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/connection_pool.rb:361:in call'C:/ Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/ string_coercion.rb:25:incall’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/head.rb:9:in call'c:/jruby-1.5.0/lib/ruby/gems/ 1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:incall’C:/
Microblogging_release1.3/vendor/rails/actionpack/lib/action_controller/
params_parser.rb:15:in call'C:/Microblogging_release1.3/vendor/rails/ actionpack/lib/action_controller/session/cookie_store.rb:93:incall’C:/Microblogging_release1.3/vendor/rails/actionpack/lib/
action_controller/failsafe.rb:26:in call'C:/Microblogging_release1.3/ vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:incall’C:/Microblogging_release1.3/vendor/rails/railties/lib/rails/rack/
static.rb:31:in call'c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:48:incall’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/urlmap.rb:40:in each'c:/jruby-1.5.0/lib/ruby/gems/ 1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:incall’C:/
Microblogging_release1.3/vendor/rails/railties/lib/rails/rack/
log_tailer.rb:17:in call'c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/ rack-1.0.1/lib/rack/content_length.rb:13:incall’c:/jruby-1.5.0/lib/
ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in call'c:/ jruby-1.5.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/ mongrel.rb:64:inprocess’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/
mongrel-1.1.5-java/lib/mongrel.rb:159:in process_client'c:/ jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb: 158:ineach’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/
lib/mongrel.rb:158:in process_client'c:/jruby-1.5.0/lib/ruby/gems/1.8/ gems/mongrel-1.1.5-java/lib/mongrel.rb:285:inrun’c:/jruby-1.5.0/lib/
ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in
initialize'c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/ lib/mongrel.rb:285:innew’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/
mongrel-1.1.5-java/lib/mongrel.rb:285:in run'c:/jruby-1.5.0/lib/ruby/ gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:268:ininitialize’c:/
jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:
268:in new'c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/ lib/mongrel.rb:268:inrun’c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/handler/mongrel.rb:34:in run'C:/ Microblogging_release1.3/vendor/rails/railties/lib/commands/server.rb: 111C:/Microblogging_release1.3/vendor/rails/railties/lib/commands/ server.rb:31:inrequire’c:/jruby-1.5.0/lib/ruby/site_ruby/1.8/
rubygems


(The table invitation_workflows has the following
columns(invitation_workflow_id,invitor_id,invited_whom_id,invited_for_channel_id,invite_status)
What exactly is the problem here,can’t get by what it means.

Thanks in Advance

Regards
Chandrika

On Mar 17, 2011, at 8:33 AM, Chandu80 wrote:

(The table invitation_workflows has the following
columns
(invitation_workflow_id
,invitor_id,invited_whom_id,invited_for_channel_id,invite_status)
What exactly is the problem here,can’t get by what it means.

Thanks in Advance

What the error says is you do not have an id column. All tables which
back an ActiveRecord Model must include an auto-incrementing primary
key, by tradition named ‘id’. There are no exceptions to this as far
as I know.

If you are making a “join model”, then you also have to have an id.
The only exception would be a habtm relationship join, which by
definition can only have two columns: model_a_id and model_b_id.

Walter

On Mar 17, 12:33pm, Chandu80 [email protected] wrote:

Client Ip : 127.0.0.1
User Id : 101346
Exception : ActiveRecord::ActiveRecordError: ERROR: column “id” does
not exist
Position: 322: INSERT INTO
“invitation_workflows” (“invitation_workflow_id”, “invitor_id”,
“invited_whom_id”, “invited_for_channel_id”, “invite_status”,
“created_by”, “updated_by”, “created_at”, “updated_at”) VALUES(NULL,
5088, NULL, 21218, ‘P’, ‘101346’, ‘101346’, ‘2011-03-17
11:58:45.553000’, ‘2011-03-17 11:58:45.553000’) RETURNING “id”

Rails assumes the presence of a primary key column called id. If it’s
called something else then you need to tell rails this (via the
set_primary_key method). Have you?

Fred

Hi Frederick,
Thanks for the response.Yes primary key was not set.I set it and it
worked. :slight_smile:

Hi Walter,
Thanks for the information. :slight_smile:

Regards
Chandrika

On Mar 17, 5:38pm, Frederick C. [email protected]

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