Rails 4: where to place Struct?

user1463822

Where should I put a simple Struct so that every model/controller would be able to use it?

Errors = Struct.new(:file_name, :errors)

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

BroiSatse

You need to place it anywhere in your load paths and the file needs to be named 'errors.rb'. Best place probably would be within lib, assuming you have added it to your load_paths in your config/application.rb:

config.autoload_paths << config.root.join('lib')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails 4: where to place Struct?

From Dev

Where to place Grape custom validations in Rails 4

From Dev

Where to place my environment dependent gem config in Rails 4?

From Dev

Where to place generic methods in Rails?

From Dev

Where to place Fixtures that are not associated with a model in Rails

From Dev

Where is the best place to store layout logic in Rails?

From Dev

Where to place a global variable in Rails inside Nav

From Dev

Where to place an Include for it to be available for the entire Rails app?

From Dev

Rails 4 - best_in_place: Unprocessable Entity

From Dev

Rails 4 Best in place select collection

From Dev

Rails 4 - Where Attribute is Blank

From Dev

Where to place logic for parsing data before saving to database in Rails?

From Dev

Where's the right place for text lookup in Ruby on Rails

From Dev

Rails : Where is the best place to put rspec files for modules in lib directory?

From Dev

Rails : Where is the best place to put rspec files for modules in lib directory?

From Dev

Where to place logic for parsing data before saving to database in Rails?

From Dev

Where do I place a file that exntends the hash class in Rails?

From Dev

Where do I place model extension methods in Rails 5.1

From Dev

Rails 4 - best_in_place gem and many-to-many association

From Dev

What may be preventing in-place editing in my rails 4 app?

From Dev

Rails 4 - best_in_place gem and many-to-many association

From Dev

Rails 4: undefined method `where' for Array:

From Dev

How to chain where conditions with "or" in Rails 4?

From Dev

rails 4 where method for date on a datetime field

From Dev

Query for records where a column is not nil in Rails 4

From Dev

Rails 4 safely using variables in "Where" method

From Dev

Rails 4 - Where do vendor assets go?

From Dev

Rails 4: Where to put data migration

From Dev

rails 4- where to put user function

Related Related

  1. 1

    Rails 4: where to place Struct?

  2. 2

    Where to place Grape custom validations in Rails 4

  3. 3

    Where to place my environment dependent gem config in Rails 4?

  4. 4

    Where to place generic methods in Rails?

  5. 5

    Where to place Fixtures that are not associated with a model in Rails

  6. 6

    Where is the best place to store layout logic in Rails?

  7. 7

    Where to place a global variable in Rails inside Nav

  8. 8

    Where to place an Include for it to be available for the entire Rails app?

  9. 9

    Rails 4 - best_in_place: Unprocessable Entity

  10. 10

    Rails 4 Best in place select collection

  11. 11

    Rails 4 - Where Attribute is Blank

  12. 12

    Where to place logic for parsing data before saving to database in Rails?

  13. 13

    Where's the right place for text lookup in Ruby on Rails

  14. 14

    Rails : Where is the best place to put rspec files for modules in lib directory?

  15. 15

    Rails : Where is the best place to put rspec files for modules in lib directory?

  16. 16

    Where to place logic for parsing data before saving to database in Rails?

  17. 17

    Where do I place a file that exntends the hash class in Rails?

  18. 18

    Where do I place model extension methods in Rails 5.1

  19. 19

    Rails 4 - best_in_place gem and many-to-many association

  20. 20

    What may be preventing in-place editing in my rails 4 app?

  21. 21

    Rails 4 - best_in_place gem and many-to-many association

  22. 22

    Rails 4: undefined method `where' for Array:

  23. 23

    How to chain where conditions with "or" in Rails 4?

  24. 24

    rails 4 where method for date on a datetime field

  25. 25

    Query for records where a column is not nil in Rails 4

  26. 26

    Rails 4 safely using variables in "Where" method

  27. 27

    Rails 4 - Where do vendor assets go?

  28. 28

    Rails 4: Where to put data migration

  29. 29

    rails 4- where to put user function

HotTag

Archive