I'm writing a Rails app that takes a text file upload from a user, manipulates it, and redisplays it. The manipulation would take place in the create action. I have the program that manipulates it in another file. I don't know what the correct pattern is for linking these things together.
My questions:
1.) Where in the directory are helper programs like these supposed to be stored? Is there a certain way these should be used from the controller?
2.) Is it a good idea to put these kinds of things in background jobs, or are those just for recurring tasks/accessing services that aren't a part of the app?
Thanks!
If you want to access the function in just one controller, its probably best to simply place it inside that specific controller as a private method, for example:
private def myFunction // manipulate file end
You could also put it in your application_controller.rb, in which case the function would be available to all of your controllers, as a protected method.
Not completely sure, but I don't think I would put it in a background job because the function is only called when a user uploads a file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.