- First-use of the message template
<% renders messages/_message.html.erb %>
<%= render @messages %>- Form submitting via Ajax
<%= form_for @project.messages.new, remote: true do |form| %>
...| unless File.exist?('Gemfile') | |
| File.write('Gemfile', <<-GEMFILE) | |
| source 'https://rubygems.org' | |
| gem 'rails', github: 'rails/rails' | |
| gem 'arel', github: 'rails/arel' | |
| gem 'sqlite3' | |
| GEMFILE | |
| system 'bundle' | |
| end |
| /** | |
| * Use em or rem font-size in Bootstrap 3 | |
| */ | |
| @font-size-root: 14px; | |
| @font-unit: 0rem; // Pick em or rem here | |
| // Convert all variables to em |
| git branch -m old_branch new_branch # Rename branch locally | |
| git push origin :old_branch # Delete the old branch | |
| git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
| # activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
| # Maps logical Rails types to MySQL-specific data types. | |
| def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
| return super unless type.to_s == 'integer' | |
| case limit | |
| when 1; 'tinyint' | |
| when 2; 'smallint' | |
| when 3; 'mediumint' | |
| when nil, 4, 11; 'int(11)' # compatibility with MySQL default |
| # app/models/concerns/multiparameter_attribute_assignment.rb | |
| module MultiparameterAttributeAssignment | |
| include ActiveModel::ForbiddenAttributesProtection | |
| def initialize(params = {}) | |
| assign_attributes(params) | |
| end | |
| def assign_attributes(new_attributes) |
| Ruby 2.1.0 in Production: known bugs and patches | |
| Last week, we upgraded the github.com rails app to ruby 2.1.0 in production. | |
| While testing the new build for rollout, we ran into a number of bugs. Most of | |
| these have been fixed on trunk already, but I've documented them below to help | |
| anyone else who might be testing ruby 2.1 in production. | |
| @naruse I think we should backport these patches to the ruby_2_1 branch and | |
| release 2.1.1 sooner rather than later, as some of the bugs are quite critical. | |
| I'm happy to offer any assistance I can to expedite this process. |
| # Thanks to this post: | |
| # http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x | |
| $ brew install cabextract | |
| $ cd ~/Downloads | |
| $ mkdir consolas | |
| $ cd consolas | |
| $ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe | |
| $ cabextract PowerPointViewer.exe | |
| $ cabextract ppviewer.cab |
<% renders messages/_message.html.erb %>
<%= render @messages %><%= form_for @project.messages.new, remote: true do |form| %>
...| class ApplicationController < ActionController::Base | |
| before_filter :ensure_xhr | |
| private | |
| def ensure_xhr | |
| if request.get? && request.format && (request.format.js? || request.format.json?) | |
| head :forbidden unless request.xhr? | |
| end | |
| end | |
| end |
| # db/migrate/XXXXXXXXXXXXX_add_authentication_token_to_users.rb | |
| class AddAuthenticationTokenToUsers < ActiveRecord::Migration | |
| def change | |
| add_column :users, :authentication_token, :string | |
| add_index :users, :authentication_token, :unique => true | |
| end | |
| end |