ActiveRecord::StatementInvalid: OCIError: ORA-00904

235 views
Skip to first unread message

rajend...@gmail.com

unread,
Apr 9, 2014, 8:09:14 AM4/9/14
to oracle-...@googlegroups.com
Hello All,

I just started trying to use the Oracle enhanced adapter and it's
failing for me. 

Models:
class Fact < ActiveRecord::Base

self.set_table_name "fact_prp"

end

When am trying to run the below statements in rails console am getting this error

Error:
-------

Could not log "sql.active_record" event. NoMethodError: undefined method `name' for :returning_id:Symbol
ActiveRecord::StatementInvalid: OCIError: ORA-00904: "ID": invalid identifier: 


Statements
----------------

fact = Fact.new
fact.prp_month_skey = '201403'
fact.save

Can anyone please help me to resolve this issue.....

With Regards,
Rajendra P.

Lori M Olson

unread,
Apr 9, 2014, 12:06:13 PM4/9/14
to oracle-...@googlegroups.com
ActiveRecord makes assumptions about primary keys.  It is expecting to find a primary key on your fact_prp table called "ID".  If your primary key is called something else, you will also need to set it as well.  Should look something like:

class Fact < ActiveRecord::Base

  self.table_name = :fact_prp
  self.primary_key = :my_primary_key

end

I've updated your code to use the current idiom of table_name= and primary_key= instead of the older style set_table_name and set_primary_key (which you will still find examples of everywhere).

I've also imposed (feel free to ignore) my own preference for using symbols in place of strings, where the string is, in fact, a constant.

Hope that helps.

Regards, Lori

--
You received this message because you are subscribed to the Google Groups "Oracle enhanced adapter for ActiveRecord" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oracle-enhanc...@googlegroups.com.
To post to this group, send email to oracle-...@googlegroups.com.
Visit this group at http://groups.google.com/group/oracle-enhanced.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages