Skip to content

Instantly share code, notes, and snippets.

1.9.3-p0 :001 > Product.last
Product Load (1.2ms) SELECT "products".* FROM "products" ORDER BY "products"."id" DESC LIMIT 1
=> #<Product id: 1, user_id: nil, department_id: nil, asset_id: nil, price: nil, description: nil, keywords: nil, created_at: "2012-10-09 13:29:25", updated_at: "2012-10-09 13:29:25", title: "Hello">
1.9.3-p0 :002 > search = Product.search do
1.9.3-p0 :003 > fulltext "Hello"
1.9.3-p0 :004?> end
=> <Sunspot::Search:{:fq=>["type:Product"], :q=>"Hello", :fl=>"* score", :qf=>"keywords_text title_text description_text", :defType=>"dismax", :start=>0, :rows=>30}>
1.9.3-p0 :005 > search.results
Product Load (0.8ms) SELECT "products".* FROM "products" WHERE "products"."id" IN (1)
=> [#<Product id: 1, user_id: nil, department_id: nil, asset_id: nil, price: nil, description: nil, keywords: nil, created_at: "2012-10-09 13:29:25", updated_at: "2012-10-09 13:29:25", title: "Hello">]
@janjiss
janjiss / gist:3859272
Created October 9, 2012 14:45
FUR REICH
geocoded_by :full_address
def full_address
country + " " + city + " " + street
end
%img.webshrinker{:src => "http://www.webshrinker.com/thumbnails/show/key:50751d71d3051/size:xlarge/url:#{@department.homepage}"}
- if can? :manage, department
.language
= department.language
= link_to("Edit",edit_department_path(department), :class => "options")
|
= link_to("Delete",department, :method => :delete, :data=>{:confirm => 'Are you sure?'}, :class => "options")
Started DELETE "/admin/departments/3?locale=lv" for 213.226.141.140 at 2012-11-08 07:44:22 +0100
Processing by Admin::DepartmentsController#destroy as HTML
Parameters: {"authenticity_token"=>"TH7mxPzf3lKsfR7AXKNNWWH0diQL74A0KWmXH/br8hI=", "locale"=>"lv", "id"=>"3"}
Completed 500 Internal Server Error in 45ms
NoMethodError (undefined method `destroy' for nil:NilClass):
app/controllers/admin/departments_controller.rb:66:in `destroy'
Sent mail to [email protected] (54ms)
Rendered static_pages/contacts.html.haml within layouts/application (6.8ms)
Completed 500 Internal Server Error in 70ms
ActionView::Template::Error (undefined method `file' for nil:NilClass):
23: - for member in @company_members
24: .company-member
25: .image
26: = image_tag(member.assetimage.first.file.url)
27: .name-surname
ActionView::Template::Error (uninitialized constant ActionView::CompiledTemplates::Iso3166):
47: = image_tag("bullet-drop.png")
48: .selectOptions
49: - @header_search_countries.each do |country|
50: %span.selectOption{:value => Iso3166.localize(country), "data-country"=> country}
51: = Iso3166.localize(country)
52: .search
53: = form_tag(search_departments_path, :method => :get) do
app/views/layouts/_header.html.haml:50:in `block in _app_views_layouts__header_html_haml__3447680631664877753_58989880'
app/views/layouts/_header.html.haml:49:in `each'
@janjiss
janjiss / gist:4193295
Created December 3, 2012 07:12
Raw upload helper
require 'mime/types'
#
# Built with massive inspiration (ok, more like following their lead) from the following:
# - https://github.com/JackDanger/file-uploader/commit/03ed9ba68d46805e22a0014ac0eee9ecbd5acd8d
# - https://github.com/newbamboo/example-html5-upload/blob/master/lib/rack/raw_upload.rb
#
class RawFileUpload
def initialize(app)
@app = app
%a#link_to_principles{:href => "#principles"}= t("agree_to_these_principles")
%div{:style => "display:none"}
#principles
.block-margin#our-vision
%h3
= t("static_pages.vision.our-values")
%p
%strong= t("seven_columns")
%ol
@janjiss
janjiss / Faster way of finding activities
Created February 2, 2013 07:58
Faster way of finding activities
class User < ActiveRecord::Base
attr_accessible :name
has_many :activities
def activities_for(day)
activities_hash = activities.where(
["created_at > ? AND created_at < ?",
day.at_midnight,
day.end_of_day]