[Rails] How to easily implement numbers with pull-down


About this article
A user registration function is implemented during the production of my own matching app. Among them, if the item of "age" can be implemented by pull-down instead of hand-made I thought it would be good if UX could be improved. When I looked it up, it was so easy to implement that I will post it as a memorandum!

[environment] ・ Ruby 2.6.5 Rails 6.0.0 ・ MacOS


Premise
It is assumed that the user management function has already been installed using the "device" gem.

app > views > devise > registrations > new.html.erb

Originally, it was described as follows for implementation by hand.

<%= f.text_field :age, autocomplete: "off" %>

Let's change it from "text" to "number"!

<%= f.number_field :age, autocomplete: "off" %>

It was easy to implement!

Recommended Posts

[Rails] How to easily implement numbers with pull-down
How to easily create a pull-down in Rails
[Rails] How to implement scraping
[Rails] How to implement star rating
How to get along with Rails
How to implement search functionality in Rails
[Rails] How to use rails console with docker
How to implement TextInputLayout with validation function
How to implement ranking functionality in Rails
How to implement image posting using rails
How to build Rails 6 environment with Docker
How to implement search function with rails (multiple columns are also supported)
How to write Rails
[Rails] How to implement unit tests for models
How to create multiple pull-down menus with ActiveHash
How to uninstall Rails
How to implement a like feature in Rails
How to build API with GraphQL and Rails
[Rails] How to build an environment with Docker
[Rails] How to easily introduce slick (slider function)
How to implement UICollectionView in Swift with code only
How to make batch processing with Rails + Heroku configuration
How to implement login request processing (Rails / for beginners)
[Rails] How to search by multiple values ​​with LIKE
How to implement guest login in 5 minutes in rails portfolio
How to implement a like feature in Ajax in Rails
How to push an app developed with Rails to Github
[Rails, JS] How to implement asynchronous display of comments
How to delete a new_record object built with Rails
How to make an almost static page with rails
How to manually generate a JWT with Rails Knock
[How to insert a video in haml with Rails]
How to query Array in jsonb with Rails + postgres
Rails learning How to implement search function using ActiveModel
How to get started with creating a Rails app
[Docker + Rails] How to deal with Rails server startup failure
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to use rails join
How to number (number) with html.erb
How to update with activerecord-import
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Java] How to implement multithreading
[Rails] How to install reCAPTCHA
[Rails] How to use Scope
How to automatically generate ER diagram when migrating with Rails6
How to set environment variables when using Payjp with Rails
How to easily implement in-app purchase using itemstore <Implementation: Android>
[With back tricks] How to introduce React to the simplest Rails