Skip to content

Instantly share code, notes, and snippets.

@elliotcm
Created June 15, 2010 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotcm/439250 to your computer and use it in GitHub Desktop.
Save elliotcm/439250 to your computer and use it in GitHub Desktop.
def read_only_collection(section_name)
get "/#{section_name}" do
haml "#{section_name}/index".to_sym
end
get "/#{section_name}/:object_name" do
begin
haml "#{section_name}/#{params[:object_name]}".to_sym
rescue Errno::ENOENT
throw :halt, [404, "Not found"]
end
end
end
private :read_only_collection
read_only_collection('projects')
read_only_collection('showcase')
read_only_collection('opinion')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment