Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #28 from animesht/master

Not found error and suggestions for FedoraRPMs
  • Loading branch information...
commit 6f4a045799787f1e9e286f65eeb2ee6bc5c99337 2 parents 8ebabc9 + 85fd29c
@movitto movitto authored
View
11 app/controllers/fedorarpms_controller.rb
@@ -9,12 +9,21 @@ def index
def show
@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
@dependencies = @rpm.dependency_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
+ def not_found
+ @rpm = params[:id]
+ @results = FedoraRpm.where('name LIKE ?', "%#{@rpm}%")
+ end
+
def full_deps
@name = params[:id]
@rpm = FedoraRpm.find_by_name(@name)
View
18 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)
View
1  config/routes.rb
@@ -21,6 +21,7 @@
get :full_dependents, :on => :member
get :by_owner, :on => :member
get :badge, :on => :member
+ get :not_found, :on => :member
end
resources :rubygems, :constraints => { :id => /.*/ }
resources :searches
Please sign in to comment.
Something went wrong with that request. Please try again.