0

I have a class Region that extended StaticModel::Base. I set data with function

set_data_file 'db/static/regions.yml'

Yes, I get what I want - I have a static model. And I have a access to my data

Region.find(1)

It work.

But I need to register this class.

ActiveAdmin.register Region do ... end

And I have a error - 'undefined method column_names'. I add a method column_names, from source code ActiveRecord's, but it not resolve problem because then I have a errors (undefined method reorder and so on) I added methods from ActiveRecord until I have error (undefined method ransack).

But when I call my normal objects activerecord I have:

City(id: integer, name: string ...)

And when I call my class Region I have just

Region

And I can use only find method - and it work.

And when I call Region.first I have:

<Region:0x007fc6e35028d0 @attributes={"active"=>true ... }, @id=1>

Thanks for help

2
  • Hey, I checked out StaticModel::Base. It seemed like it doesn't include ActiveRecord methods in it anyway. The methods it has are defined by the base from the scratch. I wouldn't recommend adding methods from ActiveRecord until it gets fixed. About the ransack method, ActiveAdmin has Ransack in its dependency, and Ransack adds method to ActiveRecord classes. So since StaticModel::Base and ActiveRecord ain't related in anyway, the error is natural.
    – limekin
    Jun 4, 2015 at 15:42
  • And why have you decided to store the data on and retrieve from a yml file ?
    – limekin
    Jun 4, 2015 at 15:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.