Skip to content

Instantly share code, notes, and snippets.

Toronto List
============
Clothes
-------
* Vestido rayas naranja/rosa/granate
* Vestido gris bolsillos
* Vestido negro corazones
* Vestido negro lino
GeoArch - Required Features 1.0
------------
* Users can create an account, and login into the application to obtain some extra features
* Users can add new info about an interesting architechtural points (name, description, photos, location)
* Users can view info added by themselves or by other users
* Users can edit (change, delete) info added by themselves
valakirka@miskatonic:~$ rake gems:install
gem install <gem> --source http://gems.github.com
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have ~/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Successfully installed <gem>
1 gem installed
<% form_for :ipoint, :html => { :multipart => true }, :url => { :action => "create" } do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :description %><br />
class Ipoint < ActiveRecord::Base
belongs_to :user
has_attached_file :photo
validates_attachment_presence :photo
end
def create
@ipoint = current_user.ipoints.build(params[:ipoint])
if @ipoint.save
flash[:notice] = 'Ipoint was successfully created.'
redirect_to(@ipoint)
else
flash[:notice] = 'There was an issue while saving the Ipoint'
render :action => "new"
end
end
class AddPhotoColumnsToIpoints < ActiveRecord::Migration
def self.up
add_column :ipoints, :photo_file_name, :string
add_column :ipoints, :photo_content_type, :string
add_column :ipoints, :photo_file_size, :integer
add_column :ipoints, :photo_updated_at, :datetime
end
GeoArch - Required Features 9-8-09
----------------------------------
* Multiple images creation and edition for an ipoint.
* Simple search for ipoints by name?
* Users can create a route with several points.
* Users can edit the routes they create.
* Logged users can save the routes they create too.
Hash.class_eval do
def deep_search(key)
res=[]
res << self[key]
values.select{|v| v.is_a?(Hash) || v.is_a?(Array)}.each do |ha|
children=ha.deep_search(key)
res+= children if children
end
res.compact!
res.empty? ? [] : res
@valakirka
valakirka / gist:265225
Created December 29, 2009 09:13 — forked from rails/gist:264500
Rails 3
products = Product.where("price = 100").limit(5) # No query executed yet
products = products.order("created_at DESC") # Adding to the query, still no execution
products.each { |product| puts product.price } # That's when the SQL query is actually fired
class Product < ActiveRecord::Base
named_scope :pricey, where("price > 100")
named_scope :latest, order("created_at DESC").limit(10)
end