Skip to content

Instantly share code, notes, and snippets.

Avatar
💥

Stu C stuartchaney

💥
View GitHub Profile
@stuartchaney
stuartchaney / highcharts includes
Created Apr 9, 2011
include the nessecary files
View highcharts includes
<%= javascript_include_tag "jquery-1.4.2", "rails", "highcharts" %>
@stuartchaney
stuartchaney / highcharts js code
Created Apr 9, 2011
ruby embedded highcharts js
View highcharts js code
<div id="fb_chart" style="width: 100%; height: 300px;"></div>
<% content_for :javascripts do %>
<script type="text/javascript">
new Highcharts.Chart({
chart: { renderTo: 'fb_chart', defaultSeriesType: 'area' },
title: { text: 'Facebook Publish to Token Rate per Day' },
xAxis: { type: 'datetime' },
View searchlogic config
config.gem searchlogic
View searchlogic config
config.gem searchlogic
View searchlogic examples
Post.name_not_like(‘foo”)
Equates to:
SELECT * FROM "posts" WHERE (post.name NOT LIKE '%foo%')
View gist:911537
Post.name_like(“foo”).views_gt(50).views_lt(200)
SELECT * FROM "posts" WHERE ((posts.views < 200) AND ((posts.views > 50) AND (post.name LIKE '%foo%')))
View gist:911538
Post.category_type like(“fun”)
Post Load (0.4ms) SELECT "posts".* FROM "posts" INNER JOIN "categories" ON "categories".id = "posts".category_id WHERE (categories.type LIKE '%fun%')
View gist:911539
Product.search(:category_type_like => "fun").
View gist:911541
@search = Post.search(params[:search])
@posts = @search.all
View gist:911543
<% form_for @search do |f| %>
<ul>
<li>
<%= f.label :name_like, "Name" %>
<%= f.text_field :name_like %>
</li>
<li>
<%= f.label :category_id_equals, "Category" %>
<%= f.collection_select :category_id_equals, Category.all, :id, :name, :include_blank => true %>
</li>