Skip to content

Commit

Permalink
Should return 404 for non-existing users/phenotypes/snps
Browse files Browse the repository at this point in the history
  • Loading branch information
philippbayer committed Jul 30, 2012
1 parent 6229098 commit d3340b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class ApplicationController < ActionController::Base
ssl_allowed :all
end

def not_found
raise ActionController::RoutingError.new("Not found")
end

private

def current_user_session
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/phenotypes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class VariationRecommender < Recommendify::Base
def show
#@phenotypes = Phenotype.where(:user_id => current_user.id).all
#@title = "Phenotypes"
@phenotype = Phenotype.find(params[:id])
@phenotype = Phenotype.find(params[:id]) || not_found
@comments = PhenotypeComment.where(:phenotype_id => params[:id]).all(:order => "created_at ASC")
@phenotype_comment = PhenotypeComment.new
@user_phenotype = UserPhenotype.new
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/snps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def index
end

def show
@snp = Snp.find_by_name(params[:id].downcase)
@snp = Snp.find_by_name(params[:id].downcase) || not_found
@title = @snp.name
@comments = SnpComment.where(:snp_id => @snp.id).all(:order => "created_at ASC")
@users = User.find(:all, :conditions => { :user_snp => { :snps => { :id => @snp.id }}}, :joins => [ :user_snps => :snp])
Expand Down Expand Up @@ -190,7 +190,7 @@ def json_element(params)
end

def find_snp
@snp = Snp.find(params[:id].downcase)
@snp = Snp.find(params[:id].downcase) || not_found

# If an old id or a numeric id was used to find the record, then
# the request path will not match the post_path, and we should do
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def index

def show
# showing a single user's page
@user = User.find_by_id(params[:id])
@user = User.find_by_id(params[:id]) || not_found
@title = @user.name + "'s page"
@first_name = @user.name.split.first
@user_phenotypes = @user.user_phenotypes
Expand Down
2 changes: 1 addition & 1 deletion serverscript
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#/bin/bash

screen -d -m -S "Server" bundle exec rails s
screen -d -m -S "Server" bundle exec rails s -e production
screen -d -m -S "Solr" bundle exec rake sunspot:solr:run
screen -d -m -S "Redis" redis-server
screen -d -m -S "Resque-worker" bundle exec rake environment resque:work QUEUE=*
Expand Down

0 comments on commit d3340b7

Please sign in to comment.