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

Out of index C/C++ -

regex - PatternSyntaxException: while using String.ReplaceAll function in java? -

objective c - how Set autolayout for multiple dynamic buttons and labells in iOS? -