1

New to ruby, trying to figure out how to debug this problem - I've been working on a search method, and the search call returns correctly on the server, but not the console.

Item.where() { has_keyword "phone" }

returns [] on the server, returns a list with 15 objects on the console. What kinds of differences exist between the server and console? Where should I start looking?

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367

1 Answers1

0

is "has_keyword" a function inside of your app or a function that is native to rails? If you have written that function yourself you may need to include the file before you can access the function from rails.

How do I call controller/view methods from the console in Rails?

My advise would be to write the function as a model scope so you can then access it by saying something like Item.has_keyword("Phone")

http://guides.rubyonrails.org/active_record_querying.html#scopes

Community
  • 1
  • 1
Abram
  • 39,950
  • 26
  • 134
  • 184