View the original gist: https://gist.github.com/428105
visit "/projects"
visit post_comments_path(post)
# If we save a record using ember-data's RESTadapter, and it fails, Rails | |
# returns the validation errors of the model as JSON hash: | |
# | |
# {"errors":{"name":["may not be blank"]}} | |
# | |
# This patches the RESTadapter to add these errors to the invalid record. It | |
# can be removed when the following Pull Request was merged into ember-data: | |
# https://github.com/emberjs/data/pull/376 | |
DS.RESTAdapter.reopen |
### Router.js.coffee | |
App.Router.reopen | |
rootURL: '/' | |
location: 'auto' | |
App.Router.map -> | |
@resource 'users', -> | |
@resource 'user', path: '/:id', -> | |
@route 'edit' |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Bootstrap Dropdown Select Ember Component" /> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<script src="http://code.jquery.com/jquery-2.0.2.js"></script> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> | |
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> | |
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script> |
// stupid dirty hack until we get rid of turbolinks and its twisted tricks that break | |
// the web :() | |
(function() { | |
var hackForTurboLinks = function(App) { | |
var initialized, reset, rootElementSelector; | |
App.deferReadiness(); | |
rootElementSelector = App.rootElement; | |
initialized = false; | |
reset = function() { | |
if ($(rootElementSelector).length) { |
/** @jsx React.DOM */ | |
var STATES = [ | |
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', | |
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', | |
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', | |
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY' | |
] | |
var Example = React.createClass({ |
View the original gist: https://gist.github.com/428105
visit "/projects"
visit post_comments_path(post)
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
<div class="input short"> | |
<%= data_f.label :number_format, _("Style de formatage des nombres") %> | |
<%= data_f.select :number_format, NumberFormat.options_for_select %> | |
</div> | |
<div class="input short"> | |
<%= data_f.label :date_format, _("Style de formatage des dates") %> | |
<%= data_f.select :date_format, DateFormat.options_for_select %> | |
</div> |
class SimpleLinearRegression | |
def initialize(xs, ys) | |
@xs, @ys = xs, ys | |
if @xs.length != @ys.length | |
raise "Unbalanced data. xs need to be same length as ys" | |
end | |
end | |
def y_intercept | |
mean(@ys) - (slope * mean(@xs)) |
<?php
use yii\base\Model;
use yii\helpers\ArrayHelper;
public function actionBatchUpdate()
{
$items = Item::find()->all();
// Делаем ключом массива уникальное поле модели