save_and_open_page
have_button(locator)
#Session controller provides a token | |
#/controllers/api/sessions_controller.rb | |
class Api::SessionsController < Devise::SessionsController | |
before_filter :authenticate_user!, :except => [:create] | |
before_filter :ensure_params_exist, :except => [:destroy] | |
respond_to :json | |
def create | |
resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
return invalid_login_attempt unless resource |
... | |
cell.recalculate | |
... | |
class Sheet | |
def build_sheet | |
... | |
cell = ValueCell.new(self,"A1","A2") | |
... | |
cell.recalculate |
def available_types | |
ClassName.state_machines[:message_type].states.map &:name | |
end |
ln -s /home/Data1 /home/Stores/abc | |
ln -f -s /home/Data2 /home/Stores/abc |
Factory.define :item do |f| | |
include ActionDispatch::TestProcess | |
f.name "Macbook Pro 15" | |
f.price_in_dollars 1500 | |
f.photo fixture_file_upload('/files/avatar.jpg', 'image/jpg') | |
end |
class Interval < ActiveRecord::Base | |
validates_presence_of :start_date, :end_date | |
# Check if a given interval overlaps this interval | |
def overlaps?(other) | |
(start_date - other.end_date) * (other.start_date - end_date) >= 0 | |
end | |
# Return a scope for all interval overlapping the given interval, including the given interval itself |
class LoLSerializer < ActiveModel::Serializer | |
... | |
hash["super_trooper"] = options[:super_trooper] | |
... | |
end | |
.. | |
#Usage: | |
ActiveModel::ArraySerializer.new(ololol_collection, | |
each_serializer: LoLSerializer, super_trooper: params[:super_trooper]).to_json |
child_coll = Mongoid.default_session[:children] | |
Parent.all.each do |p| | |
p.childs.all.each do |c| | |
c.attributes['parent_id'] = p.id | |
child_coll.insert c.attributes # save children to separate collection | |
end | |
p.childs = nil # remove embedded data |
2015-01-29 Unofficial Relay FAQ
Compilation of questions and answers about Relay from React.js Conf.
Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.
Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).