Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #28 from animesht/master
Browse files Browse the repository at this point in the history
Not found error and suggestions for FedoraRPMs
  • Loading branch information
movitto committed Dec 24, 2012
2 parents 8ebabc9 + 85fd29c commit 6f4a045
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/controllers/fedorarpms_controller.rb
Expand Up @@ -9,12 +9,21 @@ def index


def show def show
@name = params[:id] @name = params[:id]
@rpm = FedoraRpm.find_by_name(@name, :include => :rpm_comments) @rpm = FedoraRpm.find_by_name!(@name, :include => :rpm_comments)
@page_title = @rpm.name @page_title = @rpm.name
@dependencies = @rpm.dependency_packages @dependencies = @rpm.dependency_packages
@dependents = @rpm.dependent_packages @dependents = @rpm.dependent_packages
#We can register a global error handler inside the application controller for this.
rescue ActiveRecord::RecordNotFound
redirect_to :action => 'not_found'

end end


def not_found
@rpm = params[:id]
@results = FedoraRpm.where('name LIKE ?', "%#{@rpm}%")
end

def full_deps def full_deps
@name = params[:id] @name = params[:id]
@rpm = FedoraRpm.find_by_name(@name) @rpm = FedoraRpm.find_by_name(@name)
Expand Down
18 changes: 18 additions & 0 deletions app/views/fedorarpms/not_found.html.haml
@@ -0,0 +1,18 @@
%h1 RPM Not Found

Sorry, we couldn't find
%b=@rpm
as a Fedora RPM; please check your URL and try again.
%br/
%br/
- if @results != []

%table.table.table-striped.table-condensed
%thead
%tr
%th Did you mean:

%tbody
- @results.each do |r|
%tr
%td= link_to r.rpm_name, fedorarpm_path(r.rpm_name)
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -21,6 +21,7 @@
get :full_dependents, :on => :member get :full_dependents, :on => :member
get :by_owner, :on => :member get :by_owner, :on => :member
get :badge, :on => :member get :badge, :on => :member
get :not_found, :on => :member
end end
resources :rubygems, :constraints => { :id => /.*/ } resources :rubygems, :constraints => { :id => /.*/ }
resources :searches resources :searches
Expand Down

0 comments on commit 6f4a045

Please sign in to comment.