Skip to content

Instantly share code, notes, and snippets.

View jkeck's full-sized avatar
:shipit:

Jessie Keck jkeck

:shipit:
View GitHub Profile
class YourController < ApplicationController
def my_json
response, @document = get_solr_response_for_doc_id
render :text => @document.my_json, :layout => false
end
def our_json
response, @document = get_solr_response_for_doc_id
render :text => @document.export_as(:our_json), :layout => false
end
<div id="searchbox">
<h2 class="search"><%= label_tag(:q, "Search ") %></h2>
<% form_tag root_path, :method => :get do %>
<span id="search_box_and_link">
<%= text_field_tag(:q, localized_params[:q], :class=>"search") %>
</span>
<noscript>
<%= label_tag(:search_field, " in ") %>
<%= select_tag(:search_field, options_for_select(search_fields, h(localized_params[:search_field])), :title => "Targeted search options") %>
</noscript>
# Entering in tabs as \t so that it's easier to understand where the tab
mybuffer = "1\tabc\txyz\tjan1
\tdef\tlmn\tfeb1
2\tamy\tmorgan\tmay1
\tnick\tcary\tmay6"
test_hash = {}
gid = ""
#Split on new line so each line
mybuffer.split(/\n/).each do |line|
#split the line on the \t (tab) character so that we have 4 columns (groupid, first name, last name, birthday)
#this is your output buffer simulated in a hash
mybuffer = {"1"=>[{:parser_first_name=>"abc",:parser_last_name=>"xyz",:parser_bday=>"jan1"},
{:parser_first_name=>"def",:parser_last_name=>"lmn",:parser_bday=>"feb1"}],
"2"=>[{:parser_first_name=>"amy",:parser_last_name=>"morgan",:parser_bday=>"may1"},
{:parser_first_name=>"nick",:parser_last_name=>"cary",:parser_bday=>"may6"}]
}
test_hash = {}
mybuffer.each do |groupid,people|
people.each do |person|
<html>
<body>
<%= some_method %>
</body>
</html>
<%= some_text("LOCATION1") %>
<!-- This will only load once, and fail upon refresh -->