Rails 5 Ruby 2.5.3 If statements based on ranges of months

Rails 5 Ruby 2.5.3 If statements based on ranges of months

so I'm working on a personal project.

so I'm working on a personal project.

I'm a truck driver and i am building a simple app to track and calculate revenue ect..

What I am trying to do (and there may be a much better way to do it) is highlight what my current active fuel surcharge is based only on a range of months.

In this case its April 1 to Oct 31 and Nov 1 to March 31 this can change as contract requirements dictate ect.

I have an activeDate and endDate column in my database and this is what I have come up with (but doesn't seem to work).

**<<index.html.erb>>**

  &lt;tbody&gt;
    &lt;% @fscs.each do |fsc| %&gt;
      &lt;% if Date.today === (fsc.activeDate..fsc.endDate) %&gt;
        &lt;tr&gt;
          &lt;td class="fsc_active"&gt;&lt;%= fsc.name %&gt;&lt;/td&gt;
          &lt;td class="fsc_active"&gt;&lt;%= fsc.rate %&gt;&lt;/td&gt;
          &lt;td class="fsc_active"&gt;&lt;%= fsc.activeDate %&gt;&lt;/td&gt;
          &lt;td class="fsc_active"&gt;&lt;%= fsc.endDate %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'View', fsc %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Edit', edit_fsc_path(fsc) %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Delete', fsc, method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;% else %&gt;
        &lt;tr&gt;
          &lt;td class="fsc_inactive"&gt;&lt;%= fsc.name %&gt;&lt;/td&gt;
          &lt;td class="fsc_inactive"&gt;&lt;%= fsc.rate %&gt;&lt;/td&gt;
          &lt;td class="fsc_inactive"&gt;&lt;%= fsc.activeDate %&gt;&lt;/td&gt;
          &lt;td class="fsc_inactive"&gt;&lt;%= fsc.endDate %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'View', fsc %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Edit', edit_fsc_path(fsc) %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to 'Delete', fsc, method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
    &lt;% end %&gt;
  &lt;/tbody&gt;

Any advice on where I'm going wrong or pointers on how to make this better would be greatly appreciated! please let me know if more information is needed.

ruby ruby-on-rails

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Ruby on Rails Developer | Hire RoR Developer

#1 Ruby on Rails development company. Hire Ruby on rails developer or a team to build secure, scalable and complex web solutions with a quick turnaround time.

Explain Ruby on rails MVC

Our Ruby on Rails Training will provide you to learn about Rails and web applications development with realty. Our Ruby on Rails Course also includes live sessions.

"Rewrite your Software," says Creator of Ruby on Rails

David Heinemeier Hansson is the creator of Ruby on Rails, co-founder & CTO of Basecamp, best-selling author, Le Mans class-winning race car driver, family man, frequent podcast guest, and inspirational conference speaker.

Pros & Cons you must know before using Ruby on Rails for your startup

Click here, free ruby on rails course videos for you. It shows you best way to complete Ruby certification. OnlineITGuru guides you towards easy Web script

Ruby on Rails Performance Tuning

Synchronises Assets between Rails and S3. Contribute to AssetSync/asset_sync development by creating an account on GitHub.