Skip to content

Instantly share code, notes, and snippets.

Asynchronous Javascript and XML

how to make something with ajax?

  • form
<%= form_for [@question, @answer], remote: true do |f| %>
<div>
  <%= f.text_area :body %>
</div>
<%= f.submit %>

Integration Test

  • brew install qt

  • gem 'capybara'

  • gem 'laundry'

  • create a features folder in rspec

 rails g rspec:feature campaigns
  • in rails_helper.rb, include capybara/rails as a required gem

Simple form

  • gem
gem 'bootstrap-sass'
gem 'simple_form'
  • create a bootstrap_and_overrides.scss file, put in the following:
@import "bootstrap-sprockets";

Attach file

gem 'quiet_assets'
gem 'carrierwave'
bundle
rails g uploader Image

CodeCore Day 42 - OAuth

Server --> Credentials --> Twitter Server <-- Tokens <-- Twitter Server --> Redirect --> Twitter Server <-- Info <-- Twitter

  • require a Gem
  • we're using gem: omniauth
@jennli
jennli / node.md
Last active March 16, 2016 22:12

Node

  • installation
npm install express --save
npm install -g express-generator
  • running the above commands should enable a express function:
rails g model reward campaign:references title amount:integer
rake db:migrate
  • in campaign model, set up the association and nested attributes
  • the reject_if: :all_blank will ignore this input(not throwing any validation error) if user didn't put in any value for this reward object
has_many :rewards, dependent: :destroy
# this enables us to create associated rewards models at the same time we're

Finite State Machine

gem 'aasm'
  • add a aasm state field to the campaign model
g migration add_aasm_state_to_campaigns aasm_state:string:index
  • migration file looks like this:

Geocoding

gem 'geocoder'
gem 'gmaps4rails'
gem 'underscore-rails'
  • application.js
//= require underscore