I'm making a function that displays the time when the user presses the button, but the view format is
When I want to change it, you can create time_formats.rb in initializers and write the format, or use strftime, but if you haven't registered the time anyway, you will get an argument error.
For now, it's better to display if the data is available, but it's better than the if statement, but it feels bad.
Are there other ways?
Answer # 1
I don't understand the situation well ...
As a method like
format_time (t), if t is nil,
""is used, and if there is a non-nil value, the formatted string Isn't it better to prepare and use a method that returns?
- about errors when building ruby on rails environment
- ruby on rails - about followings when defining
- ruby on rails - rails tutorial about git config settings
- ruby - about require in rspec of rails application
- about input in the form in ruby on rails
- ruby on rails - about 504 gateway time-out solution in rails tutorial
- ruby on rails - about specifying rails url helper
- progate ruby on rails Ⅸ question about defining instance method in class
- ruby on rails - about column settings you want to add with devise_parameter_sanitizer of devise using multiple models
- ruby on rails - about has_many
- ruby on rails - about introducing bootstrap to rails
- ruby on rails 6 - [rails] about can't quote file error in find_or_create_by
- ruby - about errors related to migration files in rails development
- ruby on rails - about rails other_user
- ruby on rails - about changing gemfile when developing in docker environment
- i'm confused about how to write ruby on rails
- ruby - about validation of rails application record and active model
- ruby on rails - about render
- ruby on rails - about nested routing urls
- ruby on rails - there is something i don't know about the association between models
- ruby - when editing the initial value of text_field
- ruby - i don't know how to put data scraped by nokogiri into sqlite3 database
- ruby - i want to display the chart of chartkick in index for each record of the table
- ruby - how to pass data from rails 6 model to vuejs
- ruby - [rails] i want to get the latest multiple data from the database
- ruby - rails db:create cannot be done rails + postgresql environment construction
- ruby - i get an argumenterror
- you can do redirect_to with ruby on rails, but you get nomethoderror when rendering