Rails 4: where to place Struct? -


Where should I place a simple structure so that every model / controller can use it?

Errors = Straight.New (: file_name ,: errors)

Right now I'm just defining this structure in every model.

You have to place it anywhere in your load path and name the file as 'errors.rb' needed. The best place will probably be within lib , assuming that you have it in your config / application.rb :

  config Load_paths are added in. Autoload_paths & lt; & Lt; Config.root.join ('lib')    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -