diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 49523d5..196811e 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -6,6 +6,11 @@ class ItemsController < ApplicationController def index @items = Item.all end + + def search + st = "%#{params[:q]}%" + @items = Item.where("title like ?", st) + end # GET /items/1 # GET /items/1.json diff --git a/app/views/items/search.html.erb b/app/views/items/search.html.erb new file mode 100644 index 0000000..295f9b1 --- /dev/null +++ b/app/views/items/search.html.erb @@ -0,0 +1,44 @@ +
<%= notice %>
+
+ Console: <%= item.console %>
+
+ Brand: <%= item.brand %>
+
+ Genre: <%= item.genre %>
+
<%= item.description %>
+ +<%= item.price %>
+ ++ Add to cart + <%= link_to 'Show', item, :class => "button", :role => "button" %> + + <% if user_signed_in? %> + <%= link_to 'Edit', edit_item_path(item), :class => "button", :role => "button" %> + <%= link_to 'Destroy', item, method: :delete, data: { confirm: 'Are you sure?' }, :class => "button", :role => "button" %> + <% end %> + + + +
+