Skip to content

Instantly share code, notes, and snippets.

@andersosthus
Created February 15, 2011 20:39
Show Gist options
  • Select an option

  • Save andersosthus/828198 to your computer and use it in GitHub Desktop.

Select an option

Save andersosthus/828198 to your computer and use it in GitHub Desktop.

Revisions

  1. andersosthus created this gist Feb 15, 2011.
    3 changes: 3 additions & 0 deletions _searchresults.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <% @searchresults.each do |movie| %>
    Found: <%= movie.name %> | <%= movie.id %><br />
    <% end %>
    15 changes: 15 additions & 0 deletions index.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <center><h1>My movies</h1></center>
    <%= form_tag movies_path, :method => :get, :remote => true do %>
    <p>
    <%= search_field_tag :search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
    </p>
    <% end %>
    <div id="searchresults">
    <% if not @searchresults.nil? %>
    <%= render @searchresults %>
    <% end %>
    </div>

    <hr>
    <%= render 'layouts/movies' %>
    1 change: 1 addition & 0 deletions index.js.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    $("#searchresults").html("<%= escape_javascript(render(@searchresults)) %>");
    12 changes: 12 additions & 0 deletions movies_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    class MoviesController < ApplicationController

    def index
    @title = "My movies"
    @movies = Movie.all
    if params[:search]
    Tmdb.api_key = "XXX"
    @searchresults = TmdbMovie.find(:title => params[:search], :expand_results => false)
    end
    end

    end