This file contains 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
class View < ActiveRecord::Base | |
belongs_to :item, polymorphic: true | |
class << self | |
attr_accessor :user | |
end | |
before_create :set_user | |
private |
This file contains 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
# Do you want something like this... | |
class CitiesDatatable < Datatable | |
datatable class_name: 'City', search_keys: [:name] | |
end | |
# where you would access the Datatable information like this, where self == controller.view_context ... | |
cities_datatable = CitiesDatatable.new(self) | |
cities_datatable.to_json # => { sEcho: 1, iTotalRecords: 20, iTotalDisplayRecords: 10, aaData: [...] } |
This file contains 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
class FooBar < ActiveRecord::Base | |
... | |
def program_ids_list=(list) | |
self.program_ids = list.split(',') | |
end | |
end |
This file contains 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
line_1_array_of_integers = gets.chomp.split(" ").map(&:to_i) | |
line_2_array_of_integers = gets.chomp.split(" ").map(&:to_i) | |
puts line_1_array_of_integers | |
puts line_2_array_of_integers |
This file contains 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
/* Simple JavaScript Inheritance | |
* By John Resig http://ejohn.org/ | |
* MIT Licensed. | |
*/ | |
// Inspired by base2 and Prototype | |
(function(){ | |
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; | |
// The base Class implementation (does nothing) | |
this.Class = function(){}; |
This file contains 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
class CommentComponent | |
include Rafters::Component | |
attribute :subject | |
attribute :body | |
default :comment, nil | |
private | |
This file contains 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
class ApplicationController | |
before_filter :override_current_user | |
... | |
private | |
def override_current_user | |
class_eval <<-METHODS, __FILE__, __LINE__ + 1 | |
def current_user_with_sharding | |
do_stuff |
This file contains 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
# Get your project into GitHub | |
cd /your/project/directory | |
git init . | |
git add -A . | |
git commit -m "Initial import" | |
git remote add origin https://github.com/[user]/[repo].git | |
git push origin master | |
# After making some changes | |
git add -A . |
This file contains 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
var fetchPartialWithDatepicker = function (pathToPartial) { | |
var request = $.ajax({ | |
method: 'GET', | |
url: pathToPartial, | |
data: { | |
whatever: "foo" | |
} | |
}); | |
request.done(function (html) { |
This file contains 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
$.get(url ,function(table){ | |
$('#'+lang).hide().html(table).fadeIn(1000); | |
var dateField = $('.dateField', $('#'+lang)); | |
if (dateField.length > 0) { | |
dateField.datepicker({ options: "and", whatever: "you need" }); | |
} | |
}); |
OlderNewer