ãåå¿è ð°ãrails ã€ã³ã¹ã¿ã³ã¹å€æ°ã®äœ¿ãæ¹ã«ã€ããŠè³ªåã§ãã
解決ãããããš
ã¹ã±ãžã¥ãŒã«ç®¡çã¢ããªãäœæäžã§ãã
ãããããŒãžã®footerã«æ¬æ¥ã®æ¥ä»ã衚瀺ãããããšèããŠããŸãã
çŸåšfooterã«çŽæ¥Date.current.strftime("%Y幎 %mæ %dæ¥")
ãšæžã蟌ãã§è¡šç€ºãããŠããŸããã
railsã«ãããŠã¯controllerãçšããèšè¿°ã®æ¹ã奜ãŸãããšæãã
controllerãšã€ã³ã¹ã¿ã³ã¹å€æ°ãçšããæ¹æ³ã«ããã£ã¬ã³ãžããŠã¿ãŸããã
ã§ããäžæã衚瀺ããããªãç¶æ³ã§ãïŒãšã©ãŒã«ããªããŸãããïŒ
以äžè©²åœéšåã§ãã
views>layouts>application.html.erbã®footeréšå
<footer>
<h1><%= @date1 %></h1>
</footer>
controllers>application_controller.rb
class ApplicationController < ActionController::Base
def act1
@date1 = Date.current.strftime(â%Y/%m/%dâ)
end
end
controllerãšviewã®ããŒãžã察å¿ããŠããã°ã€ã³ã¹ã¿ã³ã¹å€æ°ãåæ ããããšæã£ãã®ã§ãã
衚瀺ããããªãã®ã¯äœãåå ãªã®ããæ瀺é ãããšå¬ããã§ãã
ïŒdef ã®èšè¿°ãééããŠããã®ã§ããããïŒãããšãæžã蟌ãcontrollerã®ããŒãžãéãã®ã§ããããâŠïŒ