Skip to content

Instantly share code, notes, and snippets.

@murugan-r
murugan-r / gist:3046056
Created July 4, 2012 08:19 — forked from lunks/gist:953763
i18n issue
class Order < ActiveRecord::Base
has_many :order_items
validates_length_of :order_items, :minimum => 1, :message => :empty
accepts_nested_attributes_for :order_items
end
#en.yml
activerecord:
@murugan-r
murugan-r / add.js.erb
Created July 4, 2012 08:20 — forked from amardaxini/add.js.erb
redis i18n
<tr>
<td><%=@key.split(".").drop(1) %></td>
<td><%= @value%></td>
</tr>
@murugan-r
murugan-r / 0-readme.md
Created October 2, 2012 07:57 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

Overview

This script installs a patched version of ruby 1.9.3-p194 with boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Many thanks to funny-falcon for the performance patches.

This is how we test that all translation keys match up between locales.

Stuff that only goes in one locale (such as an admin section) or that can't be translated yet (if you use external translators) can simply go in files that don't match the path "config/locales/??.yml", like "config/locales/wip.fo.yml".

# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
#!/usr/bin/ruby1.9.1 -Kw
# -*- coding: utf-8 -*-
class Edge
attr_accessor :src, :dst, :length
def initialize(src, dst, length = 1)
@src = src
@dst = dst
@length = length

Rails 4 Differences

Chapter 1

No differences.

Chapter 2

  • root :to => "dashboard#index" is now root "dashboard#index"`
  • Need to permit parameters within Subscribem::AccountsController
# put the cookbook path in solo.rb file.
echo 'cookbook_path ["/opt/aws/opsworks/current/site-cookbooks"]' > solo.rb
# create json file incase if you want use the attributes from opsworks.
opsworks-agent-cli get_json > attributes.json
#run chef-solo
/opt/aws/opsworks/current/bin/chef-solo -c solo.rb -o cookbook_name::default -j attributes.json --log_level=debug
curl -kL http://install.perlbrew.pl | sed "/\$PERLBREWDOWNLOAD/{N;s|$|sed -i -r '/@INC/ s/([)][}])/ vendorlib vendorarch\\\1/' \\\$LOCALINSTALLER\n|}" | bash
@murugan-r
murugan-r / active_record_objects_autosave.md
Last active September 19, 2015 09:23 — forked from demisx/active_record_objects_autosave.md
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.