- Put this code at #{Rails.root}/db/seeds.rb
- type
rake db:setup
It supports only `id' primary key.
class RealtyRequestController < ApplicationController | |
#... other actions ... | |
def search | |
@s = Search.new(RealtyRequest,params[:search]) do |s| | |
s.contract_id :eq # value to search defaults to params[:search][:contract_id] | |
s.price_max :lteq # same here | |
s.price_min :gteq | |
s.zone :matches, "%#{params[:search][:zone]}%" # here I look for '%param%' | |
s.province :matches, "%#{params[:search][:province]}%" | |
s.municipality :matches, "%#{params[:search][:municipality]}%" |
if Rails.version == '2.3.8' && Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) && self.class.const_defined?(:Mongrel) | |
# Pulled right from latest rack. Old looked like this in 1.1.0 version. | |
# | |
# def [](k) | |
# super(@names[k] ||= @names[k.downcase]) | |
# end | |
# | |
module Rack |
Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.
Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.
Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com
here.
Your app/widgets
directory can get crazy pretty fast. If you're learning Apotomo, then you'll probably move things around and try many ways to order your widgets directory. This is not so much about that - I still haven't found a good way to organize my widgets, but I've found a way to keep the widget classes themselves DRY.
And it should look something like this:
# A BaseWidget to apply stuff to widgets across
# the board. All widgets should inherit from this
class ApplicationWidget < Apotomo::Widget
include ActionController::RecordIdentifier # so I can use dom_id
// to build: | |
// lessc <filename> > site.css | |
// lessc <filename> > site.min.css --compress | |
// the swatch | |
@color1: #55626b; | |
@color2: #6c9380; | |
@color3: #c1ca55; | |
@color4: #f07d6b; | |
@color5: #ad5472; |
directory = './tmp/' | |
# ajax upload | |
if params[:qqfile].class == String | |
name = params[:qqfile] | |
string_io = request.body | |
data_bytes = string_io.read | |
path = File.join(directory, name) | |
File.open(path, "w") do |f| | |
f.write(data_bytes) | |
end |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv='X-UA-Compatible' content='IE=edge' /> | |
<title>SAPUI5 Contacts Demo</title> | |
<script id="sap-ui-bootstrap" | |
type="text/javascript" | |
src="http://localhost/sapui5/resources/sap-ui-core.js" | |
data-sap-ui-theme="sap_goldreflection" | |
data-sap-ui-libs="sap.ui.commons,sap.ui.commons,sap.ui.table,sap.ui.ux3" |
this.selectize = this.$("#js-tags").selectize({ | |
persist: true, | |
maxItems: null, | |
valueField: "tag", | |
labelField: "tag", | |
searchField: ["tag"], | |
options: tags.toJSON(), // Backbone collection | |
render: { | |
item: function(item) { | |
return "<div><i class='icon-tag'></i> " + item.tag + "</div>"; |
# Multiple inheritance with Modules as an alternative to injected composition | |
# from Sandi Metz's talk [Nothing is Something](http://confreaks.tv/videos/bathruby2015-nothing-is-something) | |
# Like Sandi's 'direct' DI method this has behavior outside of the base class | |
# that gets composed together. However in this gist I compose modules in class | |
# definitions instead of injecting collaborators. | |
# Tradeoffs between this and Sandi's version are that in this case the API consumer doesn't | |
# have to know how to make a RandomEchoHouse (no `house = House.new(formatter: Whatever.new)`), | |
# but also the API consumer can't make anything not already accounted for either. |