Skip to content

Instantly share code, notes, and snippets.

@dtolj
dtolj / gist:847440
Created February 28, 2011 15:17
Rails: Non-db field
#new.haml
-form_for(@webcast, :url=>{:action=>"create"}, :html=> {:id=>"wrf",:multipart => true }) do |f|
= f.label :presenter_Name,"Presenter Name:*"
= f.text_field :presenter_Name
= f.label :presenter_Email,"Presenter Email:*"
= f.text_field :presenter_Email
#How to pass these non-db values to server in HTTP POST?
=select_tag "presenter_name_email[]","",html_options = {:size=>"5", :multiple => true}
=button_to_function "Add", "", html_options={:id=>"add"}
@dtolj
dtolj / gist:842669
Created February 24, 2011 19:02
jQuery appendTo list
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
//If you want to move selected item from fromListBox to toListBox
$("#add").click(function() {
//$("#fromListBox option:selected").appendTo("#toListBox");
$("#fromListBox").appendTo("#toListBox");
@dtolj
dtolj / gist:842417
Created February 24, 2011 16:43
jquery
$(document).ready(function(){
var r=function rem(e){
alert("Hello World");
};
$("#remove").click(r);
});
@dtolj
dtolj / gist:833771
Created February 18, 2011 15:03
Nokogiri block assignment
[myxml]
<item>
<title>Book1</title>
<author>Bob</author>
<link>http://url1.com</link>
</item>
<item>
<title>Book2</title>
<author>Bob</author>
<link>http://url1.com</link>
@dtolj
dtolj / gist:827613
Created February 15, 2011 14:57
Happymapper with attributes
I have the following XML doc:
<objects>
<item>
<title>book1</title>
<link>http://asdf.com</link>
<pubDate>march 1 2009</pubDate>
<description>testtesttest</description>
<media:thumbnail url='http://url.com' />
</item>
<item>
def index
@site=Site.new
end
-form_for @site, :url=>{:action=>:create} do |f|
=f.error_messages
=f.label :original_address
=f.text_area (:original_address,:size=>"100x20")
=f.submit "GeoCode"
@dtolj
dtolj / gist:786400
Created January 19, 2011 16:25
sorting
class Peripheral < ActiveRecord::Base
has_many :quotes, :order=>"peripheral_id"
end
class Quote < ActiveRecord::Base
belongs_to :peripheral
end
def admin
session[:item]=params[:val]
@dtolj
dtolj / gist:784634
Created January 18, 2011 16:02
Ruby MS access create database
#
#
#
#
#
require 'rubygems'
require 'win32ole'
require 'csv'
mdb_file="c:/dtolj/ruby_projects/phone.accdb"
@dtolj
dtolj / gist:745517
Created December 17, 2010 19:09
routing
scope "/geosites" do
root :to => "sites#index"
end
$rake routes
sites_index GET /sites/index(.:format) {:action=>"index", :controller=>"sites"}
root /geosites(.:format) {:action=>"index", :controller=>"sites"}
http://mysite.com/geosites
No route matches "/"
@dtolj
dtolj / gist:744298
Created December 17, 2010 00:43
mysql on RH linux
gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --with-mysql config=/usr/lib/mysql/mysql_config