Skip to content

Commit

Permalink
#86 - Defining method find local by name
Browse files Browse the repository at this point in the history
Co-authored-by: Zarbielli <jlfz06@gmail.com>
Co-authored-by: heronsousa <heronrsousa@hotmail.com>
  • Loading branch information
zarbielli and heronsousa committed Sep 10, 2018
1 parent fad0375 commit 8cddd09
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions indicaAi/app/controllers/locals_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class LocalsController < ApplicationController

#GET /locals
def allLocals
locals = Local.all
render json: locals
end

#GET /locals/name/:name
def searchLocals
locals = Local.findByName(params[:name])
render json: locals
end

end
2 changes: 0 additions & 2 deletions indicaAi/app/controllers/locals_controller_controller.rb

This file was deleted.

4 changes: 4 additions & 0 deletions indicaAi/app/models/local.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class Local < ApplicationRecord
def self.findByName(params)
locals = Local.where('upper(name) = ?', params.upcase)
return locals
end
end

0 comments on commit 8cddd09

Please sign in to comment.