Friday, February 26, 2016

Week 5 - Movie Review app - Carrierwave, Fog, Rmagick, Fog-aws, Mini-magick

Click here to go to website
Yesterday I began the movie review app.  I was excited about this one.  I love love love movies and I love to see the art work too.  I love the way this app displays the posters in the index view so while I was making it, I decided to use fan art instead of the original posters so I could give the site a fresh but classic look.

While working on this app I had an issue with the search method.  The current way to do search is to use elastic search.  Its great and works real well.  It will do a search on all the text in the data that you are searching in.  Too bad heroku doesn't support elastic search... for free.  Yes they do support it, but you have to pay $10/month as of Feb 26, 2016.  That doesn't work for me so I used html to do search.

<%= form_tag search_movies_path, :method => 'get', class: "navbar-form", role: "search" do %>
<%= text_field_tag :search, params[:search], class: "form-control" %>
<%= submit_tag "Search", name: nil, class: "btn btn-default" %>

# I needed a search method in the corresponding movies controller.rb

 def search
  @movies = Movie.search(params[:search])
 end

# Then I created a search view search.html.erb

class="row">
  <% @movies.each do |movie| %>
  
class="col-sm-6 col-md-3">
    
class="thumbnail">
     <%= link_to (image_tag movie.image.url(:poster), class: 'image'), movie %>
   

<% end %>
The search is in the _header.html.erb partial
<%= form_tag search_movies_path, :method => 'get', class: "navbar-form", role: "search" do %>
<%= text_field_tag :search, params[:search], class: "form-control" %>
<%= submit_tag "Search", name: nil, class: "btn btn-default" %>

I needed a search method in the corresponding movies controller.rb
def search
@movies = Movie.search(params[:search])
end

Then I created a search view search.html.erb

class="row">
<% @movies.each do |movie| %>

class="col-sm-6 col-md-3">

class="thumbnail">
<%= link_to (image_tag movie.image.url(:poster), class: 'image'), movie %>
</div>

<% end %>
</div>

Here  is where I put my search results.  This search method is not the best. 
    If the search field is left blank, there are no results.
    You also have to spell whole words correctly. Iron Man will not return Ironman.

Looking forward to work with Elastic Search and any other gems that simplify my life.

Check out my github for this app.  Better yet see the app live

Features I would like to add:
1. Use an api to pull in imdb info
2. Reformat show view to a more landscape display of info.
3. Upload multiple poster.
4. Display multiple posters.
5. Show a trailer of the movie.
6. Use a better search method. Heroku has a free add-on called SearchBox Elasticsearch
7. Rich text formating

Until next week, same blog chanel, same blog time,

Kenyacode

No comments:

Post a Comment