The view file of rails is not readable, so I want to make it a form helper.
Please write your question in detail here.
Made the contents of the view file a form helper.
However, arrays such as ["10", "2010135152"] are displayed together and cannot be implemented well.
There are two problems, and it is difficult to implement. A reference article is fine. Please give me advice.
reducation_time wants to convert a number to time and display it.
I want to use integer type or string type.
Site ⇒ http://188.8.131.52/projects
View file code, dirty ...
What I tried
<% @ projects.each do | project |%> <tr> <td><% = project.id%></td> <td><% = link_to project.name, project_path (project)%></td> <td><% = project.status%></td> <td><% = project.number_of_month%>times</td> <td> <% if project.reducation_time>= 60%> <% = project.reducation_time/60%>time <% = project.reducation_time% 60%>minutes</td> <% else%> <% = project.reducation_time%>minutes <% end%> </td> <td> <% if project.number_of_month * project.reducation_time * 12>= 60%> <% = project.number_of_month * project.reducation_time * 12/60%>Time <% = project.number_of_month * project.reducation_time * 12% 60%>minutes</td> <% else%> <% = project.number_of_month * project.reducation_time * 12%>minutes <% end%> <% end%>
Try to put together in helper.rb
module ProjectsHelper def reducation_name project_id ='''' @ projects.each do | project | project_id + = project.id.to_s end return raw (project_id) end def reducation reducation_hour ='''' reducation_min ='' @ projects.each do | project | if project.reducation_time>= 60 reducation_hour + = (project.reducation_time/60) .to_s reducation_min + = (project.reducation_time% 60) .to_s else else reducation_min + = (project.reducation_time) .to_s end end binding.pry return raw (reducation_hour), raw (reducation_min) end end
Trial take out with view file
<% = reducation%> <% = reducation_name%>
Supplementary information (FW/tool version, etc.)
Answer # 1
I feel that writing like this will give you the results you expect, but how about it?
# Only the first ... I thought that product.reducation_time was displayed in minutes. <td> <% sec = project.reducation_time * 60%> <% = sec>= 3600? Time.at (sec) .strftime ('% H time% M minutes'): Time.at (sec) .strftime ('% M minutes')%> </td>
- ruby on rails - [rails] i want to use each statement in a helper method
- ruby on rails 5 - undefined method `tomorrow'for 00: i would like to know how to solve bigdecimal
- ruby on rails 6 - undefined method `id'for: article: symbol resolution in rails
- ruby on rails - i don't know where to check the method
- ruby on rails: undefined method ʻuser'for nil: about nomethoderror of nilclass
- ruby on rails undefinde method doesn't work
- ruby - undefind method chart kick in rails production environment
- ruby - no method error rails
- ruby on rails - undefined method `if'for ~
- ruby on rails - undefined method `merge'for
- ruby on rails 6 - please tell me how to read a constant file with helper in rails
- ruby - not saved with rails new save method
- ruby on rails - ndefined method `name'for nil: nilclass error is output
- ruby on rails - helper cannot be read by controller
- ruby on rails - [rails] i want to solve "no route matches [post]"/messages/search "" of "routing error&
- ruby - sprockets :: rails :: helper :: assetnotfound in posts # index i want to display the images saved in my computer
- ruby - the method defined in the model cannot be used
- ruby - unable to save comments in db (rails)
- ruby - rails: fattachment_field gives undefined method error
- i'm having trouble with ruby's word bingo algorithm
- i am creating a bulletin board with rubyonrails, but i cannot display the user name
- mysql - i'm having trouble getting the name of the person who posted the message to appear in the view
- ruby - i want to store the ids of user and group in an intermediate table
- c ++ - about support between openacc and double type
- ruby - i want to retrieve only the values of a specific column from the rails array
- html - accordion panel doesn't work well [ruby on rails]
- html - i want to display the name of the user who clicked the like next to the like function in the post list! !!
- ruby on rails - nomethoderror in itemscontroller # new error
- ruby - implementation of validation (when blank transmission)