Skip to content

Instantly share code, notes, and snippets.

@jeremiaheb
Last active August 29, 2015 14:10
Show Gist options
  • Save jeremiaheb/6a8320937b983303320e to your computer and use it in GitHub Desktop.
Save jeremiaheb/6a8320937b983303320e to your computer and use it in GitHub Desktop.
sample_path(Sample.find_by_field_id("55551J"))
def send_to_path(missing_field_id)
if Rails.application.routes.recognize_path(sample_path(@dashSamples.find_by_field_id(missing_field_id)))
sample_path(@dashSamples.find_by_field_id(missing_field_id))
else
benthic_cover_path(@dashBenthicCovers.find_by_field_id(missing_field_id))
end
end
@tdouce
Copy link

tdouce commented Nov 21, 2014

def path(field_id)
  if benthic_cover = BenthicCovers.find_by_field_id(field_id)
    benthic_cover_path(benthic_cover)
  elsif  corral_demographic = CorralDemographic.find_by_field_id(field_id)
    corral_demographic_path(corral_demographic)
  else
    sample = Sample.find_by_field_id(field_id)
    sample_path(sample)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment