Changeset 5

Show
Ignore:
Timestamp:
06/21/06 01:25:32 (3 years ago)
Author:
tim
Message:

Search is starting to work.
Fixed a typo in the database FK constraints.
Going to bed now, really.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/themes_controller.rb

    r2 r5  
    1313    @versions = [["", ""]] 
    1414    @versions += Version.find(:all, :order => "name DESC").collect { |v| [v.name, v.id] } 
     15 
     16    unless @params["search"].nil? 
     17      name = @params["search"]["name"] 
     18      @themes = Theme.find(:all, :conditions=>["name like ?", "%#{name}%"], :order=>"name ASC") 
     19    end 
    1520  end 
    1621 
  • trunk/app/views/themes/search.rhtml

    r1 r5  
    11<table> 
     2  <thead> 
     3<%= form_tag({:action=>"search"}) %> 
    24  <tr> 
    35    <th>Name</th> 
     
    1214                   "version",  
    1315                   @versions) %></td> 
    14     <td><%= submit_to_remote("submit", "Search") %></td> 
     16    <td><%= submit_tag("Search") %></td> 
    1517  </tr> 
     18</form> 
     19  </thead> 
     20  <tbody> 
     21    <% unless @themes.nil? 
     22       @themes.each { |theme| %> 
     23    <tr> 
     24      <td><%= link_to theme.name, {:action=>"view", :id=>theme.id } %></td> 
     25      <td></td> 
     26      <td></td> 
     27    </tr> 
     28    <% }  
     29       end %> 
     30  </tbody> 
    1631</table> 
  • trunk/db/migrate/001_initial_schema.rb

    r1 r5  
    1818 
    1919      execute "ALTER TABLE themes_versions ADD CONSTRAINT theme_id_fkey FOREIGN KEY (theme_id) REFERENCES themes(id);" 
    20       execute "ALTER TABLE themes_versions ADD CONSTRAINT version_id_fkey FOREIGN KEY (version_id) REFERENCES themes(id);" 
     20      execute "ALTER TABLE themes_versions ADD CONSTRAINT version_id_fkey FOREIGN KEY (version_id) REFERENCES versions(id);" 
    2121    end 
    2222  end 
  • trunk/db/schema.rb

    r1 r5  
    77  create_table "themes", :force => true do |t| 
    88    t.column "name", :string 
     9    t.column "display_name", :string 
    910  end 
    1011