[Vuejs]-Send search results to json with rails

0๐Ÿ‘

Iโ€™m not sure if it is your main issue but it looks your where clause is using single quotes, thus is not picking up that variable. You need to use double quotes if you want to use ruby string interpolation.

irb(main):006:0> foo = 5
=> 5
irb(main):007:0> 'this is my number #{foo}'
=> "this is my number \#{foo}"
irb(main):008:0> "this is my number #{foo}"
=> "this is my number 5"

So you want:

  def self.search(search)
    where('title LIKE ?', "%#{search}%")
  end

0๐Ÿ‘

You should set the dataType option to expect JSON data for the return value. You can do it like this:

$.ajax({
  url: '/strains.json',
  dataType: 'json',
  success: function(res){
    that.strains = res;
  }
});

Leave a comment