I have a rails app and I am looking to create an action in my controller that query's my SQLite DB and returns a Link that has a specific string in a DB column.
For instance I have a links table with a column category. I want my controller to get all categories that have a string of movies.
What does this Query look like? I posted my schema and controller that I have so far, but I am stuck.
links_controller:
def find_category
Link.where("SELECT category FROM links WHERE links LIKE '%movies%'")
end
links table:
create_table "links", force: :cascade do |t|
t.string "title"
t.string "url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.integer "cached_votes_total", default: 0
t.integer "cached_votes_score", default: 0
t.integer "cached_votes_up", default: 0
t.integer "cached_votes_down", default: 0
t.string "avatar"
t.string "category"
end
Aucun commentaire:
Enregistrer un commentaire