100 Experience
0 Lessons Completed
0 Questions Solved


Posted in Can Anyone explain me these ruby codes?

Recently I am started learning ruby on rails. I am doing a project on ruby on rails. In my project there are some code in application.controller.rb . But I am not understanding the meaning of the code. Can anyone please explain me these codes?

def new_year_holidays?
    t = Time.now

    @notification = t >= Rails.application.config.new_year_holidays_start_at &&
                    t <= Rails.application.config.new_year_holidays_finish_at
    start_date = Rails.application.config.new_year_holidays_start_at 
    end_date   = Rails.application.config.new_year_holidays_finish_at
    @new_year_holidays_start_at = start_date.strftime("%Y年%m月%d日(#{%w(日 月 火 水 木 金 土)[start_date.wday]})")
    @new_year_holidays_finish_at = end_date.strftime("%Y年%m月%d日(#{%w(日 月 火 水 木 金 土)[end_date.wday]})")

I installed ruby 2.5.1 and rail 5.2.1 on CentOS7 . I have an existing rail project which is 3.2.13. Now the existing rail project does not run in my local environment.
I create a new project on rail and it runs

[root@localhost html]# cd ruby_rails/
[root@localhost ruby_rails]# bin/rails server
=> Booting Puma
=> Rails 5.2.1 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://
Use Ctrl-C to stop
Started GET "/" for at 2018-10-06 21:43:25 +0900
Processing by Rails::WelcomeController#index as HTML
  Rendering /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /root/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/templates/rails/welcome/index.html.erb (11.4ms)
Completed 200 OK in 188ms (Views: 131.5ms | ActiveRecord: 0.0ms)

But I have an existing project on rails 3.2.13 that does not run on my local environment

[root@localhost html]# cd rehome_navi-master/
[root@localhost rehome_navi-master]# bin/rails server
rbenv: ruby: command not found

The `ruby' command exists in these Ruby versions:

I really need to run this project. please help me.

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2023 GoRails, LLC. All rights reserved.