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
# POST /issues | |
# POST /issues.xml | |
def create | |
@issue = Issue.new(params[:issue]) | |
# A D D N E W C A U S E / E F F E C T | |
if params[:action_carrier] | |
# Read in the :type passed with form to recognize whether this is a Cause or Effect | |
@causality = params[:action_carrier].to_s | |
@causality_id = params[:id_carrier] |
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
# POST /issues | |
# POST /issues.xml | |
def create | |
@issue = Issue.new(params[:issue]) | |
# A D D N E W C A U S E / E F F E C T | |
if params[:action_carrier] | |
# Read in the :type passed with form to recognize whether this is a Cause or Effect |
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
<% people = Person.find( | |
:conditions => ["added_at > ? and deleted = ?", Time.now.utc, false], | |
:order => "last_name, first_name") %> | |
<% people.reject { |p| p.address.nil? }.each do |person| %> | |
<div id="person-<%= person.new_record? ? "new" : person.id %>"> | |
<span class="name"> | |
<%= person.last_name %>, <%= person.first_name %> | |
</span> | |
<span class="age"> | |
<%= (Date.today - person.birthdate) / 365 %> |
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
<% if user.has_image %> | |
<td><%= image_tag(user.img, :size => "10x10") %></td> | |
<% 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
resources :your_model, :id => /[a-z0-9-]*/ |
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 img= image | |
self.has_image = true | |
AWS::S3.new.buckets[:images_cloudstock].objects[id].write(image.read) | |
end | |
def img | |
AWS::S3.new.buckets[:images_cloudstock].objects[id].url_for(:read) if has_image | |
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 User < AWS::Record::HashModel | |
string_attr :id | |
string_attr :name | |
integer_attr :age | |
string_attr :sex | |
string_attr :city | |
boolean_attr :has_image, :default => false |
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
find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[]) |
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_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[]) | |
cached(key, [name, prefix, partial], details, locals) do | |
find_templates(name, prefix, partial, details) | |
end | |
end | |
def cached(key, prefix, name, partial) | |
return yield unless key && caching? | |
@cached[key][prefix][name][partial] ||= yield | |
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
require "benchmark" | |
foo = "foo" | |
bar = "bar" | |
array = [foo, bar] | |
hash = {:a => foo, :b => bar} | |
nested_hash = Hash.new { |h,k| h[k] = {} } | |
nested_hash[foo][bar] = true |
OlderNewer