I want to get a tuple with a specific string from rails db.

Asked 2 years ago, Updated 2 years ago, 48 views

Hello, everyone I want to get a tuple with a specific string from the rails.

When I do the sql door, LIKE '% specific string%' could be searched.

Rails has several functions that use db I'd like to know if there's a function.

ruby database ruby-on-rails

2022-09-22 14:22

1 Answers

You can do it as below.

To use variables

@name = specific string
User.where("name like ?", "%" + @name + "%")

Or if you want to use it right away

User.where ("name like % specific string %")


2022-09-22 14:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.