Skip to content

Instantly share code, notes, and snippets.

= semantic_form_for :map_listing, :url => import_listings_path, :method => :post, :html => {:multipart => true} do |f|
= f.input :file, :as => :file
= f.buttons
ruby-1.9.2-p290 :101 > @foo.update_attributes!(suspended_at: Time.zone.now, suspension_reason: "Some foo reason")
=> true
ruby-1.9.2-p290 :102 > @foo
=> #<Listing _id: 4ee230142b36da01d300004d, _type: "listing" ... suspended_at: nil, suspension_reason: nil, ...>
@jonpaul
jonpaul / console.rb
Created December 8, 2011 19:47
true != 'true'
ruby-1.9.2-p290 :001 > params = {"utf8"=>"✓", "authenticity_token"=>"kAizu8XHaZw9Kw1gtUuU22nWl85WQVV5zTzurdWO1M0=", "internship"=>{"report_accepted"=>"true"}, "commit"=>"Change", "locale"=>"en", "id"=>"28"}
=> {"utf8"=>"✓", "authenticity_token"=>"kAizu8XHaZw9Kw1gtUuU22nWl85WQVV5zTzurdWO1M0=", "internship"=>{"report_accepted"=>"true"}, "commit"=>"Change", "locale"=>"en", "id"=>"28"}
ruby-1.9.2-p290 :002 > params['internship']['report_accepted'] == true
=> false
ruby-1.9.2-p290 :003 > params['internship']['report_accepted'] == 'true'
=> true
def download
@email = User.emails.concat(Organization.emails).compact!
outfile = "members_" + Time.now.strftime("%D") + ".csv"
unless @email.blank?
data = CSV.generate do |csv|
csv << ['Email']
@email.each do |e|
csv << [e]
end
end
if params[:map_listing][:file]
file_field = params[:map_listing][:file]
session[:map_fields] = {}
temp_path = File.join(Dir::tmpdir, "map_fields_#{Time.now.to_i}_#{$$}")
File.open(temp_path, 'wb') do |f|
f.write file_field.read
end
session[:map_fields][:file] = temp_path
end
CSV.foreach(session[:map_fields][:file], { :headers => true, :return_headers => true }) do |row|
class Admin::ContentsController < Admin::BaseController
before_filter :find_content, :only => [:edit, :update]
def index
@contents = Content.all
end
def edit
end
@jonpaul
jonpaul / about.html.haml
Created December 2, 2011 18:11
I must be doing this the hard way
%p#missionCopy
= raw @mission
%p#historyCopy.activeCopy
= raw @history
%p#newsCopy
= raw @news
def search
search_terms = params[:query]
orgs = Listing.search do
query {
boolean do
should { term :short_description, search_terms}
should { term :full_description, search_terms}
should { term :manufacturers_name, search_terms}
should { term :manufacturers_part_num, search_terms}
should { term :suppliers_name, search_terms}
class Boss::ListingsController < Boss::BaseController
def destroy
@listings = Listing.where(:listing_name => CGI::unescape(params[:listing_name]))
logger.debug "this is my object #{@listings.inspect}"
@listings.destroy
redirect_to boss_listings_path, :notice => "Successfully destroyed this group of listings."
end
end
@jonpaul
jonpaul / newnew.rb
Created November 18, 2011 15:14
Oh snap, translation XSS bug!
translate('foo_html', :something => '<script>') # => "...&lt;script&gt;..."