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
def find_family_view_for_state_with_caching(state, action_view) | |
return find_family_view_for_state(state, action_view) unless ActionController::Base.perform_caching | |
key = "#{state}/#{action_view.template_format}" | |
self.class.state2view_cache[key] ||= find_family_view_for_state(state, action_view) | |
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
c = ActiveRecord::Base.connection | |
c.tables.collect do |t| | |
columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id" || x.ends_with("_type"))} | |
indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq | |
unindexed = columns - indexed_columns | |
unless unindexed.empty? | |
puts "#{t}: #{unindexed.join(", ")}" | |
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
class A | |
private | |
def foo | |
puts "Private method called" | |
end | |
end | |
class B < 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
# script/generate model Post content:text | |
class Post < ActiveRecord::Base | |
alias :full_content :content | |
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
class A | |
protected | |
def foo | |
end | |
private | |
def bar | |
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
puts local_variables.inspect | |
y = 4 |
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
module ModOne | |
def hello | |
"hello1" | |
end | |
end | |
module ModTwo | |
def hello | |
"hello2" | |
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
module Utils | |
def foo | |
puts "bar" | |
end | |
def bar | |
puts "foo" | |
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
s = '[email protected]' | |
s[/^([^@]+)@(.*)/, 1] # => michal | |
s[/^([^@]+)@(.*)/, 2] # => example.com | |
s.match(/^([^@]+)@(.*)/)[1] # => michal | |
s.match(/^([^@]+)@(.*)/)[2] # => example.com | |
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
puts "Before block comment" | |
=begin | |
The method above prints a string to stdout | |
Pretty awesome! | |
And the method below does the same! | |
=end | |
puts "After block comment" |
OlderNewer