<input id="store_longitude" name="store[longitude]" size="30" type="text" />
[javascript文]
<script type="text/javascript">
document.getElementById("store_longitude").value = xxxx;
</script>
<input id="store_longitude" name="store[longitude]" size="30" type="text" />
<script type="text/javascript">
document.getElementById("store_longitude").value = xxxx;
</script>
map.enableScrollWheelZoom();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Maps JavaScript API Example - simple</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=aaaaa"
type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="map" style="width: 300px; height: 300px"></div>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.441944, -122.141944), 13);
}
GEvent.addListener(map, 'click', function(overlay, point) {
if (point) {
document.getElementById("show_x").innerHTML = point.x;
document.getElementById("show_y").innerHTML = point.y;
}
});
//]]>
</script>
<P id="show_x"></P>
<P id="show_y"></P>
</body>
</html>
<div id="map" style="width: 500px; height: 500px"></div>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(38, 138), 5);
map.disableDragging();
}
GEvent.addListener(map, 'click', function(overlay, point) {
if (point) {
alert("x = " + point.x + ", y = " + point.y);
map.openInfoWindow(point,
document.createTextNode("openInfoWindow Test"));
}
});
//]]>
</script>
(3)application.html.erbを編集。<!DOCTYPE html>
<html>
<head>
<title>Googlemap</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAABWYMASZTPMzQMXu2alSa6xTvcRCYKSpWpPqDL-sNMuxVdHFI_BTd8zF9kdpV97QhhvGd0NWsQckXsw"
type="text/javascript"></script>
</head>
<body>
<%= yield %>
</body>
</html>
(4)サーバ起動
cd file_column_test
rails plugin install git://github.com/tekin/file_column.git
--- file_column.rb.orig 2010-09-28 00:54:44.000000000 +0900
+++ file_column.rb 2010-09-28 00:55:12.000000000 +0900
@@ -594,7 +594,7 @@
# default options. You can override these with +file_column+'s +options+ parameter
DEFAULT_OPTIONS = {
- :root_path => File.join(RAILS_ROOT, "public"),
+ :root_path => File.join(Rails.root, "public"),
:web_root => "",
:mime_extensions => MIME_EXTENSIONS,
:extensions => EXTENSIONS,
class Entry < ActiveRecord::Base
file_column :image,
:root_path => "#{Rails.root}/public/store",
:web_root => "store/",
:magick => {
:versions => {
:thumb => { :crop => "1:1", :size => "50x50" },
:middle => "150x150>",
:large => "480x480>"
}
}
end
<%= form_for(@entry, :html => { :multipart => true }) do |f| %>
<% if @entry.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@entry.errors.count, "error") %> prohibited this entry from being saved:</h2>
<ul>
<% @entry.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :image %><br />
<%= file_column_field "entry", "image" %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @entry.name %>
</p>
<p>
<b>Image:</b>
<%= image_tag(url_for_image_column(@entry, "image", :middle)) if @entry.image %>
</p>
<%= link_to 'Edit', edit_entry_path(@entry) %> |
<%= link_to 'Back', entries_path %>
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @entry.name %>
</p>
<p>
<b>Image:</b>
<%= image_tag(url_for_image_column(@entry, "image", :middle)) if @entry.image %>
</p>
<%= link_to 'Edit', edit_entry_path(@entry) %> |
<%= link_to 'Back', entries_path %>
$ ruby script/generate scaffold person name:string age:integer
%export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin/:$PATH
%export MANPATH=/opt/local/man:/opt/local/share/man:$MANPATH
% curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
% tar zxvf ruby-1.8.7-p72.tar.gz
% cd ruby-1.8.7-p72
% ./configure --prefix=/usr/local --enable-shared --enable-pthread
% make
% sudo make install
% make clean
% ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.4.0]
% which ruby
/usr/local/bin/ruby
% ftp http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
% tar zxvf rubygems-1.3.1.tgz
% cd rubygems-1.3.1
% sudo ruby setup.rb
% gem -v
1.3.1
% which gem
/usr/local/bin/gem
% sudo gem install rails
% rails -v
Rails 2.3.2
% which rails
/usr/local/bin/rails
SQLiteのインストール
% port install sqlite3
sqlite3-rubyのインストール
% gem install sqlite3-ruby
% echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
require_dependency 'smtp_tls'
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
@socket.debug_output = STDERR #@debug_output
check_response(critical { recv_response() })
do_helo(helodomain)
raise 'openssl library not installed' unless defined?(OpenSSL)
starttls
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
@socket.debug_output = STDERR #@debug_output
do_helo(helodomain)
authenticate user, secret, authtype if user
@started = true
ensure
unless @started
# authentication failed, cancel connection.
@socket.close if not @started and @socket and not @socket.closed?
@socket = nil
end
end
def do_helo(helodomain)
begin
if @esmtp
ehlo helodomain
else
helo helodomain
end
rescue Net::ProtocolError
if @esmtp
@esmtp = false
@error_occured = false
retry
end
raise
end
end
def starttls
getok('STARTTLS')
end
def quit
begin
getok('QUIT')
rescue EOFError
end
end
end
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:authentication => :plain,
:user_name => 'xxxxxx@gmail.com',
:password => '******'
}
>script/generate mailer NotifyMailer result
def result(sent_at = Time.now)
subject 'NotifyMailer#result'
recipients 'xxxx@xxxxx.xxxx' #とりあえずここ修正
from 'xxxx@xxxxxx.xxx' #とりあえずここ修正
sent_on sent_at
body :greeting => 'Hi,'
end
def mail
mail = NotifyMailer.create_result()
NotifyMailer.deliver(mail)
end