This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone --depth 1 git://github.com/emberjs/data | |
cd data | |
bundle | |
bundle exec rake dist | |
copy dist/ember-data-min.js file to your project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#each person in list}} | |
<li>{{person.name}}</li> | |
{{else}} | |
There are none. | |
{{/each}} | |
{{#each person in list}} | |
{{#with person}} | |
<li>{{name}}</li> | |
{{/with}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controller | |
@tables = ActiveRecord::Base.connection.tables.sort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'prawn' | |
// Recipie Model | |
def shopping_list_pdf | |
shopping_list = ingredients.map do |ingredient| | |
[ingredient.name, ingredient.quantity] | |
end | |
pdf = Prawn::Document.new | |
pdf.table([[ "Item", "Quantity" ], *shopping_list]) do |t| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// album.rb Model | |
class Album < ActiveRecord::Base | |
def copy | |
self.class.new.tap do |new_album| | |
attributes.each do |key, value| | |
new_album.send("#{key}=", value) unless key == "id" | |
end | |
new_album.save | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Structure | |
rails g scaffold Article name:string approved:boolean | |
// routes | |
resources :articles do | |
get 'toggle_approve', :on => :member | |
end | |
// Article Helper | |
def approve_link_text(approvable) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validates_format_of :ssn, :with => /^[\d]{3}-[\d]{2}-[\d]{4}$/, :message => "must be of format ###-##-####" ==================================================== // lib/custom_validations.rb module CustomValidations def validates_ssn(*attr_names) attr_names.each do |attr_name| validates_format_of attr_name, :with => /^[\d]{3}-[\d]{2}-[\d]{4}$/, :message => "must be of format ###-##-####" end end end ActiveRecord::Base.extend(CustomValidations) // config/environment.rb require 'custom_validations' // model/student.rb class Student < ActiveRecord::Base validates_presence_of :name validates_ssn :ssn end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#search_fromDate').datepicker( | |
{ | |
dateFormat: 'dd/mm/yy', | |
onClose: function( selectedDate ){ | |
$( "#search_toDate" ).datepicker( "option", "minDate", selectedDate ); | |
$('#search_fromDate').blur(); //or .focusout(); | |
} | |
} | |
); |
NewerOlder