How to process data that needs to be stored in a database, but is not a suitable model in Ruby on Rails?

Imagine a web application written in Ruby on Rails. Part of the state of this application is presented as a part of the data that does not match the description of the model. This state descriptor must be stored in the same database as the models. Where it differs from the model, there should be only one instance of its class, and it has no relationship with other classes.

Has anyone come across something like this?

+5
source share
5 answers

From your description, I think the rails-settings plugin should do what you need.

From the Readme:

" - , . , , ActiveRecord . , rails, . , , .

http://github.com/Squeegy/rails-settings/tree/master

+3

, , .

+3

RoR; OO.

, , , , factory .

. Logger ( singleton), / .

+1

Rails, . "", - ActiveRecord Rails.

, . ( ) :

class ApplicationController < ActionController::Base
  helper :all 
  @data = "YOUR DATA HERE"   
end

, Rails.

+1

, , , Rails.

, Ruby : -)

, , , , "data":

ComplexThing.data = complex_hash.inspect

,

complex_hash = eval ComplexThing.data

:

  • Ruby, . # < MyClass: 0x4066e3c > -, - .
  • . , .
0
source

All Articles