In your view:
<%= link_to "Load more", posts_path(@posts, page: @posts.current_page+1), id: "load-more-posts", remote: true %>In your controller:
respond_to :html, :js, only: [:index]
def index| require 'benchmark' | |
| def is_it_true? | |
| true | |
| end | |
| CONSTANT = 1 | |
| BenchTimes = 1_000_000 | |
| Benchmark.bm(20) do |bm| |
| require 'sinatra' | |
| require 'action_mailer' | |
| class Mailer < ActionMailer::Base | |
| def contact | |
| mail( | |
| :to => "[email protected]", | |
| :from => "[email protected]", | |
| :subject => "Test") do |format| | |
| format.text |
In your view:
<%= link_to "Load more", posts_path(@posts, page: @posts.current_page+1), id: "load-more-posts", remote: true %>In your controller:
respond_to :html, :js, only: [:index]
def index| SELECT zip, primary_city, | |
| latitude, longitude, distance | |
| FROM ( | |
| SELECT z.zip, | |
| z.primary_city, | |
| z.latitude, z.longitude, | |
| p.radius, | |
| p.distance_unit | |
| * DEGREES(ACOS(LEAST(1.0, COS(RADIANS(p.latpoint)) | |
| * COS(RADIANS(z.latitude)) |
| // takes a {} object and returns a FormData object | |
| var objectToFormData = function(obj, form, namespace) { | |
| var fd = form || new FormData(); | |
| var formKey; | |
| for(var property in obj) { | |
| if(obj.hasOwnProperty(property)) { | |
| if(namespace) { |
| require "active_record" | |
| ActiveRecord::Base.establish_connection('postgres:///testing') | |
| ActiveRecord::Migration.verbose = false | |
| ActiveRecord::Migration.class_eval do | |
| create_table :played_quizzes, force: true do |t| | |
| t.integer :player_ids, array: true | |
| t.json :quiz_snapshot | |
| end |
| brew install openssl | |
| brew link --force openssl | |
| gem install puma | |
| ALternatively: | |
| export CPPFLAGS="-I/usr/local/opt/openssl/include" | |
| export LDFLAGS="-L/usr/local/opt/openssl/lib" | |
| gem install puma |
| function getPaginatedItems(items, page, pageSize) { | |
| var pg = page || 1, | |
| pgSize = pageSize || 100, | |
| offset = (pg - 1) * pgSize, | |
| pagedItems = _.drop(items, offset).slice(0, pgSize); | |
| return { | |
| page: pg, | |
| pageSize: pgSize, | |
| total: items.length, | |
| total_pages: Math.ceil(items.length / pgSize), |