Git Product home page Git Product logo

Comments (5)

rsim avatar rsim commented on August 21, 2024

You have not specified primary key for your table - by default it is "id" but in table creation you specified :id => false which means that "id" column is not created.

So in this case you need to use set_primary_key in your class definition to specify what is primary key (is it "identifier" or "serial"?). And you should also use set_sequence_name to specify which database sequence should be used to populate primary key value (if primary key is integer column).

Or do you want to access existing table and don't want to create new records there from ActiveRecord? In that case you don't need to create migration.

from oracle-enhanced.

bruskiza avatar bruskiza commented on August 21, 2024

This is an existing table. The schema is from the

   rake db:schema:dump

command.
I included it in order to better illustrate what I was working with.

The primary key is not too much of an issue, and it doesn't seem to fix the problem.

The real problem, as I have since discovered, is that there are 'class' and 'type' columns in this table, which absolutely, categorically mess with ActiveRecord.

I can get around the 'type' issue by using the 'set_inheritance_column' attribute and setting my model as follows (and i set the primary key):

class Status < ActiveRecord::Base
    set_table_name  "reporter_status"
    set_primary_key "serverserial"

    set_inheritance_column :ruby_type


    # getter for the "type" column
    def status_type
        self[:type]
    end

    # setter for the "type" column
    def status_type=(s)
        self[:type] = s
    end

end

but I have yet to find something similar for the class attribute.

The ActiveRecord is usable, but only by not using the generated methods, as the following example shows:

>> s = Status.first
=> #<Status identifier: ".1.3.6.1.4.1.1899", serial: 674110192, node: "node", nodealias: ...
>> s.identifier
NoMethodError: undefined method `generated_methods' for 40000:Fixnum
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:243:in `method_missing'
    from (irb):1
>> s[:class]
=> 40000
>> s[:identifier]
=> ".1.3.6.1.4.1.1899"

You can hack your views to use the 'instance[:parameter]' notation, but the UrlHelpers and thinks like that break.

I know that this is no longer an oracle_enhanced adapter issue, so if you can point me to another forum to post to, I will gladly proceed there.

In the meantime, I will head over to aptiva's ActiveRecord git repository and ask him.

Thanks.

from oracle-enhanced.

rsim avatar rsim commented on August 21, 2024

One workaround is that you could create database view on top of this table where you can rename table columns (type, class) which conflict with default Ruby methods. And then you can use set_table_name with this view in your class definition.

from oracle-enhanced.

bruskiza avatar bruskiza commented on August 21, 2024

I thought about that, and that was my next port of call.

Thanks very much.

from oracle-enhanced.

rsim avatar rsim commented on August 21, 2024

closing as we found some workaround

from oracle-enhanced.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.