All threads / How do I display just the year in a sect date?

Ask A Question


You’re not receiving notifications from this thread.

How do I display just the year in a sect date?

Rob Thomas asked in Rails

Good day Rails Devs,

What's the proper way to dsiplay just the year in:

<%= form.date_select :year %>

There are a couple options called discard_day and discard_month that you could set to true to hide them and only display the year. All the options are listed here:

Got it, thanks Chris!

<%= form.date_select :year, :discard_day   => true, :discard_month => true, class: 'form-control' %>
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 52,321+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.