Discussion:
ODBC app in Ruby - I don't believe it.
(too old to reply)
Ed Reed
2010-10-03 07:26:50 UTC
Permalink
I'm trying to figure out what's so cool about Ruby. I need to create a
web app that runs on Windows 7 and talks to multiple ODBC data sources.
I wanted to start with just a simple app but I've been trying for three
days on three different machines with no success. I tried setting up
Ruby 1.9.2, 1.9.1, 1.8.2, and 1.8.6 and can't even begin to start
developing anything.

My steps have been
Uninstall and remove all existing Ruby installations
Install Ruby
install DevKit
run command gem install rails
run command gem install rake
run command gem install mysql
run command gem install mysql2
run command rails new mydbapp -d mysql
run command rails new mydbapp -d mysql2

I've tried numerous combinations of the above steps (obviously I didn't
perform both the mysql and mysql2 at the same time) and get errors on
install rails, install mysql, install mysql2, and rails new mydbapp.

I've searched the web for three days for answers to all the different
errors. I've found that many people seem to have the same or very
similar errors and it doesn't look like there's many successful
resolutions.

So since Ruby can't create a web database app on Windows 7 and there's
no descent place to find useful answers to problems that lead to
successful resolutions, and creating a simple app requires a ridiculous
number of steps to just set it up before you ever get to write any code,
what's so cool about it? I'm serious, I'd like an answer. I'd like to
see it work but all I've seen is errors. I don't think it can do it but
I've heard people say that it's the hot new way to do web db apps. I've
been writing web db apps for the past 12 years in a variety of languages
on numerous platforms and I've never had to deal with this. I don't see
how anyone can spend this much non-billable time before your ever get to
write any code. Can anyone answer any of these questions?
--
Posted via http://www.ruby-forum.com/.
Markus Fischer
2010-10-03 09:09:35 UTC
Permalink
Hi Ed,

not much we can do here, since you didn't include any kind of error
message or specific question with a problem.

Maybe it's the Windows platform; maybe not. I'm working primarily on W7
as my workstation but it's such a horrible development environment I
always run a virtual machine either Debian or Ubuntu and therein no such
problems arose yet.

- Markus
Justin Collins
2010-10-03 09:18:03 UTC
Permalink
Post by Ed Reed
I'm trying to figure out what's so cool about Ruby. I need to create a
web app that runs on Windows 7 and talks to multiple ODBC data sources.
I wanted to start with just a simple app but I've been trying for three
days on three different machines with no success. I tried setting up
Ruby 1.9.2, 1.9.1, 1.8.2, and 1.8.6 and can't even begin to start
developing anything.
My steps have been
Uninstall and remove all existing Ruby installations
Install Ruby
install DevKit
run command gem install rails
run command gem install rake
run command gem install mysql
run command gem install mysql2
run command rails new mydbapp -d mysql
run command rails new mydbapp -d mysql2
I've tried numerous combinations of the above steps (obviously I didn't
perform both the mysql and mysql2 at the same time) and get errors on
install rails, install mysql, install mysql2, and rails new mydbapp.
I've searched the web for three days for answers to all the different
errors. I've found that many people seem to have the same or very
similar errors and it doesn't look like there's many successful
resolutions.
So since Ruby can't create a web database app on Windows 7 and there's
no descent place to find useful answers to problems that lead to
successful resolutions, and creating a simple app requires a ridiculous
number of steps to just set it up before you ever get to write any code,
what's so cool about it? I'm serious, I'd like an answer. I'd like to
see it work but all I've seen is errors. I don't think it can do it but
I've heard people say that it's the hot new way to do web db apps. I've
been writing web db apps for the past 12 years in a variety of languages
on numerous platforms and I've never had to deal with this. I don't see
how anyone can spend this much non-billable time before your ever get to
write any code. Can anyone answer any of these questions.
Hi Ed,

Sorry for your frustration. However, you seem to be conflating Ruby (the
language) and Ruby on Rails (the web framework). You might get better
answers on the Rails forum/mailing list: http://www.ruby-forum.com/forum/3

Some browsing around landed me here:
http://allaboutruby.wordpress.com/2009/07/20/installing-rails-on-windows-3-years-later/
which describes installing Ruby and Rails on Windows 7, so it certainly
is possible. Unfortunately, it does not describe using MySQL. Here's
another reference, which does mention MySQL:
http://www.hashemzahran.com/riding-the-rails-installing-ruby-on-rails/
My apologies if you have already seen these.

Without seeing the actual errors, I am afraid that's the best I can do.

-Justin
Brian Candler
2010-10-03 09:42:30 UTC
Permalink
Post by Ed Reed
I need to create a
web app that runs on Windows 7 and talks to multiple ODBC data sources.
..
Post by Ed Reed
run command gem install rails
You don't need Rails to talk to a database, nor to build a web app
(there are other options). But if you want to use Rails, then a Rails
forum would be a better place to ask. This forum is for Ruby, the
programming language.

In any case, I'd suggest you start with a basic hello-world type of web
app, perhaps using sqlite3 if you want a database, before getting it to
connect to some other data source.

You're putting yourself at a disadvantage by running under Windows, but
you could also look at some of the prepackaged bundles like Instant
Rails.

There's tons of documentation about Rails, so I'm sure with a bit of
googling you could find some quick-start guides for Rails under Windows.
Post by Ed Reed
run command gem install mysql
run command gem install mysql2
I don't use Windows myself, but I'm pretty sure you don't need the mysql
gem to talk to an ODBC data source.

For what it's worth, I do have a Rails app running under Linux talking
happily to MS SQL Server via ODBC. If I remember correctly, the bits I
needed were:

* unixODBC and unixODBC-devel
* freetds (Linux interface to SQL Server with ODBC API)
* ruby-odbc gem
* activerecord-sqlserver-adapter gem

config/environment.rb was something like:

development:
adapter: sqlserver
mode: odbc
dsn: XXXXXXX
username: xxxxxxxx
password: xxxxxxxx
--
Posted via http://www.ruby-forum.com/.
Mike Stephens
2010-10-03 10:58:27 UTC
Permalink
I created a Ruby application (Windows Vista) that read and wrote to an
Access DB. It took under 5 minutes to build. You could hardly go any
faster with Access VBA.

Stick with Ruby but think twice about Rails. It looks very good to me
but personally I can do without all the complexity right now. It's for
certain types of applications written in certain ways. You probably
don't need it.
--
Posted via http://www.ruby-forum.com/.
Michael Brooks
2010-10-03 12:13:36 UTC
Permalink
Post by Ed Reed
I'm trying to figure out what's so cool about Ruby. I need to create a
web app that runs on Windows 7 and talks to multiple ODBC data sources.
I wanted to start with just a simple app but I've been trying for three
days on three different machines with no success. I tried setting up
Ruby 1.9.2, 1.9.1, 1.8.2, and 1.8.6 and can't even begin to start
developing anything.
Hello Ed:

DBI appears to be a popular way to access to ODBC in Ruby. DBI provides a
consistence way to access multiple DBs including via ODBC if you want. One
thread I read said that the Windows Ruby Installer installs DBI
automatically but it was an old thread and I haven't tried DBI myself on
Windows (I'm on Vista) so I can't confirm but maybe these links will help
you:

http://www.tutorialspoint.com/ruby/ruby_database_access.htm
http://rubyonwindows.blogspot.com/2008/01/rubygarden-archives-scripting-access.html
http://blog.hlie.org/
http://www.kitebird.com/articles/ruby-dbi.html
http://rubyonwindows.blogspot.com/2007/06/using-ruby-ado-to-work-with-ms-access.html

There is also ruby-odbc but it appears to be used along with DBI so I'm not
sure I see the point:

http://www.ch-werner.de/rubyodbc/
http://www.ruby-forum.com/topic/113835

Sorry I couldn't be more help... I haven't used Ruby for much DB stuff yet
although I did use "instant rails" to access MySQL when using the Agile Web
Development with Rails book and it was painless to setup and get going.

Michael
Luis Lavena
2010-10-03 14:44:21 UTC
Permalink
Post by Ed Reed
I'm trying to figure out what's so cool about Ruby. I need to create a
web app that runs on Windows 7 and talks to multiple ODBC data sources.
I wanted to start with just a simple app but I've been trying for three
days on three different machines with no success. I tried setting up
Ruby 1.9.2, 1.9.1, 1.8.2, and 1.8.6 and can't even begin to start
developing anything.
My steps have been
Uninstall and remove all existing Ruby installations
Install Ruby
install DevKit
run command gem install rails
run command gem install rake
run command gem install mysql
run command gem install mysql2
run command rails new mydbapp -d mysql
run command rails new mydbapp -d mysql2
Rails 3 (latest release of it) requires either Ruby 1.8.7 or Ruby
1.9.2. If you haven't installed one of these versions you're going to
have problems.

Second, have you read Ruby on Rails guides?

http://guides.rubyonrails.org/getting_started.html
Post by Ed Reed
I've tried numerous combinations of the above steps (obviously I didn't
perform both the mysql and mysql2 at the same time) and get errors on
install rails, install mysql, install mysql2, and rails new mydbapp.
If you installed RubyInstaller, there are plenty of tutorials
explaining how to get everything installed:

http://github.com/oneclick/rubyinstaller/wiki/Tutorials
Post by Ed Reed
I've searched the web for three days for answers to all the different
errors. I've found that many people seem to have the same or very
similar errors and it doesn't look like there's many successful
resolutions.
What errors? you're not providing the output that you're receiving so
is highly unlikely we can help you without them.

It is important also that you don't confuse Rails with Ruby.

--
Luis Lavena
Ed Reed
2010-10-03 18:42:10 UTC
Permalink
WOW! Thanks for all the responses and please accept my apologies for
venting my frustrations at 1am. You'd think I'd learn my lesson and not
do that after doing this job for so many years.

I wasn't trying to confuse Ruby and Rails and I understand that the pair
is synonymous to the pair of C++ and MFC. I guess I was just excepting
that it might be an easier way to start a new app. My reason for trying
to test with mysql was just due to my experience with it and it's
already set up on my machines for development purposes.

I will definitely take a look at the links everyone supplied.

Thanks again.
--
Posted via http://www.ruby-forum.com/.
Ed Reed
2010-10-04 18:30:55 UTC
Permalink
Okay I've decided to start from scratch,... again. It's the start of a
new week and I've got a positive attitude so here we go. I read this,
http://www.kitebird.com/articles/ruby-dbi.html, and wanted to try the
first test script. When I do, I get the following error.

C:\PROGRA~2\APACHE~1\Apache2.2\htdocs\dbi-scripts>simple.rb
lib/rational.rb is deprecated
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles.rb:12:
warning: optional boolean argument is obsoleted
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in
load_driver': Unable to load driver 'Mysql' (underlying error:
uninitialized constant DBI::DBD::Mysql) (DBI::InterfaceError)
from C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
from
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:242:in
`load_driver'
from
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:160:in
`_get_full_driver'
from
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from
C:/PROGRA~2/APACHE~1/Apache2.2/htdocs/dbi-scripts/simple.rb:9:in
`<main>'


Here are the steps I took to get to here.
Fresh install of Ruby 1.9.2 using
http://rubyforge.org/frs/download.php/72170/rubyinstaller-1.9.2-p0.exe
followed by,
gem install dbd
gem install dbi-mysql
gem install dbi-odbc
gem install mysql

There were no errors generated from any of the commands above.

Then from the command prompt I tried to run the simple.rb script from
http://www.kitebird.com/articles/ruby-dbi.html. The contents of which
are,

#!/ruby -w
# simple.rb - simple MySQL script using Ruby DBI module

require "dbi"

begin
# connect to the MySQL server
#@ _CONNECT_
dbh = DBI.connect("DBI:Mysql:test:localhost", "root", "password")
#@ _CONNECT_
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
#@ _EXCEPTION_
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
#@ _EXCEPTION_
ensure
# disconnect from server
dbh.disconnect if dbh
end

I'm open to suggestions?
--
Posted via http://www.ruby-forum.com/.
Jeremy Bopp
2010-10-04 20:27:01 UTC
Permalink
Post by Ed Reed
Okay I've decided to start from scratch,... again. It's the start of a
new week and I've got a positive attitude so here we go. I read this,
http://www.kitebird.com/articles/ruby-dbi.html, and wanted to try the
first test script. When I do, I get the following error.
C:\PROGRA~2\APACHE~1\Apache2.2\htdocs\dbi-scripts>simple.rb
lib/rational.rb is deprecated
warning: optional boolean argument is obsoleted
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in
uninitialized constant DBI::DBD::Mysql) (DBI::InterfaceError)
from C:/Ruby/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
from
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:242:in
`load_driver'
from
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:160:in
`_get_full_driver'
from
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from
C:/PROGRA~2/APACHE~1/Apache2.2/htdocs/dbi-scripts/simple.rb:9:in
`<main>'
Here are the steps I took to get to here.
Fresh install of Ruby 1.9.2 using
http://rubyforge.org/frs/download.php/72170/rubyinstaller-1.9.2-p0.exe
followed by,
gem install dbd
gem install dbi-mysql
gem install dbi-odbc
The above gem commands have typos. They should be:

gem install dbi
gem install dbd-mysql
gem install dbd-odbc
Post by Ed Reed
gem install mysql
This is fetched automatically when installing the dbd-mysql gem. FYI.
Post by Ed Reed
Then from the command prompt I tried to run the simple.rb script from
http://www.kitebird.com/articles/ruby-dbi.html. The contents of which
are,
#!/ruby -w
# simple.rb - simple MySQL script using Ruby DBI module
require "dbi"
begin
# connect to the MySQL server
dbh = DBI.connect("DBI:Mysql:test:localhost", "root", "password")
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
dbh.disconnect if dbh
end
I'm open to suggestions?
It's necessary to download the MySQL client DLL and copy it into Ruby's
bin directory if you want to use the mysql gem on Windows. I downloaded
mysql-connector-c-noinstall-6.0.2-win32.zip from
http://dev.mysql.com/downloads/connector/c/ and copied the
lib/libmysql.dll file from the archive directly into Ruby's bin
directory to resolve this issue.

FYI, things are much easier under Linux. :-) I wonder if it's possible
for the mysql gem for Windows builds to provide this DLL.

-Jeremy
Ed Reed
2010-10-04 21:29:26 UTC
Permalink
My mistake on the gem commands. I did use the correct ones with dbd
instead of dbi. I copied the libmySQL.dll and the simple.rb script now
runs correctly. Thanks! I don't have much to say about the platform. The
client says it needs to run on Windows 7 so I do what I can to meet
their expectations.
I tried another example from the same kitebird.com source. The xml.rb
script produces an error that seems to indicate a bug in the either ruby
or the extensions. I don't know if I'm still missing something or is
there really a problem that needs to be fixed.

Here's the output from the command,

C:\PROGRA~2\APACHE~1\Apache2.2\htdocs\dbi-scripts>xml.rb
lib/rational.rb is deprecated
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles.rb:12:
warning: optional boolean argument is obsoleted
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130:
[BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

-- control frame ----------
c:0011 p:---- s:0051 b:0051 l:000050 d:000050 CFUNC :fetch_fields
c:0010 p:0093 s:0048 b:0048 l:000047 d:000047 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130
c:0009 p:0040 s:0040 b:0040 l:000034 d:000039 BLOCK
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:37
c:0008 p:0019 s:0038 b:0038 l:000037 d:000037 METHOD
<internal:prelude>:10
c:0007 p:0029 s:0035 b:0035 l:000034 d:000034 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:34
c:0006 p:0038 s:0030 b:0030 l:000029 d:000029 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/base_classes/database.rb:96
c:0005 p:0080 s:0024 b:0023 l:000022 d:000022 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:81
c:0004 p:0032 s:0017 b:0017 l:000016 d:000016 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128
c:0003 p:0106 s:0010 b:0009 l:000714 d:000ca8 EVAL
C:/PROGRA~2/APACHE~1/Apache2.2/htdocs/dbi-scripts/xml.rb:24
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000714 d:000714 TOP
---------------------------
-- Ruby level backtrace information
----------------------------------------
C:/PROGRA~2/APACHE~1/Apache2.2/htdocs/dbi-scripts/xml.rb:24:in `<main>'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128:in
`select_all'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:81:in
`execute'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/base_classes/database.rb:96:in
`execute'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:34:in
`execute'
<internal:prelude>:10:in `synchronize'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:37:in
`block in execute'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130:in
`column_info'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130:in
`fetch_fields'

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension
libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html


This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
--
Posted via http://www.ruby-forum.com/.
Jeremy Bopp
2010-10-05 01:48:24 UTC
Permalink
Post by Ed Reed
My mistake on the gem commands. I did use the correct ones with dbd
instead of dbi. I copied the libmySQL.dll and the simple.rb script now
runs correctly. Thanks! I don't have much to say about the platform. The
client says it needs to run on Windows 7 so I do what I can to meet
their expectations.
It's good you made it a little further but too bad your client got sold
on the MS koolaid.
Post by Ed Reed
I tried another example from the same kitebird.com source. The xml.rb
script produces an error that seems to indicate a bug in the either ruby
or the extensions. I don't know if I'm still missing something or is
there really a problem that needs to be fixed.
Here's the output from the command,
C:\PROGRA~2\APACHE~1\Apache2.2\htdocs\dbi-scripts>xml.rb
lib/rational.rb is deprecated
warning: optional boolean argument is obsoleted
[BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
-- control frame ----------
c:0011 p:---- s:0051 b:0051 l:000050 d:000050 CFUNC :fetch_fields
c:0010 p:0093 s:0048 b:0048 l:000047 d:000047 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130
c:0009 p:0040 s:0040 b:0040 l:000034 d:000039 BLOCK
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:37
c:0008 p:0019 s:0038 b:0038 l:000037 d:000037 METHOD
<internal:prelude>:10
c:0007 p:0029 s:0035 b:0035 l:000034 d:000034 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:34
c:0006 p:0038 s:0030 b:0030 l:000029 d:000029 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/base_classes/database.rb:96
c:0005 p:0080 s:0024 b:0023 l:000022 d:000022 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:81
c:0004 p:0032 s:0017 b:0017 l:000016 d:000016 METHOD
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128
c:0003 p:0106 s:0010 b:0009 l:000714 d:000ca8 EVAL
C:/PROGRA~2/APACHE~1/Apache2.2/htdocs/dbi-scripts/xml.rb:24
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000714 d:000714 TOP
---------------------------
-- Ruby level backtrace information
----------------------------------------
C:/PROGRA~2/APACHE~1/Apache2.2/htdocs/dbi-scripts/xml.rb:24:in `<main>'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128:in
`select_all'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:81:in
`execute'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/base_classes/database.rb:96:in
`execute'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:34:in
`execute'
<internal:prelude>:10:in `synchronize'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:37:in
`block in execute'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130:in
`column_info'
C:/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-0.4.4/lib/dbd/mysql/statement.rb:130:in
`fetch_fields'
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension
libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
My best guess on this is that the mysql gem was compiled against a
different version of the libmysql.dll file. As a result, it may make a
call somewhere that leads to a segfault. I think there might be a lead
in the mysql gem documentation:

http://rubydoc.info/gems/mysql/2.8.1/frames

It mentions that there is a History.txt file available somewhere that
has the major and version number for the MySQL client library used to
build the mysql gem. I don't have my work system available right now to
look for the file, but see if you can find it in your gem installation.

-Jeremy
Ed Reed
2010-10-05 23:58:20 UTC
Permalink
The history.txt file for the mysql gem says
"Binary version built against MySQL 5.0.83"
Also it shows a release date of 2009/08/21.

Is there nothing newer than this? An extension over a year old for a
bleeding-edge technology like Ruby seems a little embarrassing to me. I
looked around, I can't even find the MySQL Connector/C v5.0.83 to try
and solve the problem.

What am I missing here? This goes back to my original question. Where is
all the hype coming from? I was writing CGI apps for Windows using VB6
over 15 years ago and even back then it was a lot easier than this. I'm
willing to get on board but how much non-billable time does a person
have to spend on this stuff?
--
Posted via http://www.ruby-forum.com/.
Luis Lavena
2010-10-06 00:27:16 UTC
Permalink
Post by Ed Reed
The history.txt file for the mysql gem says
"Binary version built against MySQL 5.0.83"
Also it shows a release date of 2009/08/21.
Is there nothing newer than this? An extension over a year old for a
bleeding-edge technology like Ruby seems a little embarrassing to me. I
looked around, I can't even find the MySQL Connector/C v5.0.83 to try
and solve the problem.
There has been no updates to mysql "gem" because the extension author
(the C code the gem wraps for Ruby users) hasn't been updated since
last year.

The reason for that: author declared it dead long ago. He invested
time in ruby/mysql extension instead:

http://github.com/tmtm/ruby-mysql
Post by Ed Reed
What am I missing here? This goes back to my original question. Where is
all the hype coming from? I was writing CGI apps for Windows using VB6
over 15 years ago and even back then it was a lot easier than this. I'm
willing to get on board but how much non-billable time does a person
have to spend on this stuff?
Seems to me you started on this with the wrong foot. Learn a framework
and a language at the same time is a daunting task that requires
patience and time.

If you, your client or your company are willing to invest on that no
matter -- what framework or language we are talking about -- will be
considered a waste of time.

--
Luis Lavena
Dave Howell
2010-10-06 07:40:38 UTC
Permalink
What am I missing here? This goes back to my original question. Where =
is=20
all the hype coming from? I was writing CGI apps for Windows using VB6=20=
over 15 years ago and even back then it was a lot easier than this. =
I'm=20
willing to get on board but how much non-billable time does a person=20=
have to spend on this stuff?
I sympathize. I actually decided to learn Ruby just a few months after =
Rails was first released, so I've been programming in Ruby for years. =
However, I've been using it for OS apps, not web apps. Earlier this =
year, I finally had a chance to do some web dev, and I rubbed my hands =
together. "Oh, boy, I finally get to use Rails! I've heard it's really =
fabulous! This ought to be really fun!"

Alas, no, it was really quite a nightmare.=20

Part of the problem is that once upon a time, middleware was =
comprehensive. Active Server Pages or Tango or SilverStream or =
WebObjects, by necessity, had to include everything you needed to go =
from database to web server. With Tango (the platform I used heavily =
back in the mid '90s), I needed a working ODBC connection to my database =
(SQLServer), and a web server (IIS or WebStar), and Tango. That's it.=20

Now, everything comes in pieces, and you have to snap it together =
yourself, and there's just so much more opportunity for things to not =
fit together correctly.=20

My current web-app environment is PostgreSQL for the database, Apache =
&/or Mongrel &/or WeBrick for the web server (I really don't understand =
that part yet). The ODBC driver has been replaced with some postgres =
libraries and the pg gem. Tango has been replaced with =
Ramaze&Sequel&(mumble). "Mumble" was originally HAML, but in the end I =
just scrapped the entire idea of using a templating engine because I =
couldn't stand the limitations, so now (mumble) is some custom code I =
wrote for myself.=20

I don't think this relates to your problem, but just to give you an =
example of what can go wrong: I already had a working PostgreSQL server =
to connect with, but when I tried to install the 'pg' gem so that Ruby =
could communicate with it, the gem refused to compile because it needed =
to link with some Postgres library files. Well, I *had* a local copy of =
Postgres. So I patiently explained to the gem where it *ought* to be =
looking.=20

Once it had installed, then I tried to use it. No joy there: it was =
completely broken. It took me about three days to finally fix the =
problem. I'd installed Postgres under Mac OSX 10.4, but now I was =
running 10.6, and Apple introduced huge quantities of 64-bit code with =
10.6. The pg gem had been entirely uninterested in installing itself as =
a 'universal' build, and since it was trying to be 64-bit only, it was =
unable to link to the libraries. When I 'fixed' it, which meant making =
it build as a 32-bit app, then all my OTHER gems were broken, since I =
was now trying to mix different architectures. I eventually managed to =
get Postgres correctly rebuilt in a true multi-architecture format, but =
I wrote at least three email messages far angrier than yours sounded. (I =
just didn't actually send them to anybody. {chuckle})

I then spent yet another whole day trying to get Rails to work. I'd =
heard such glowing praise for Rails that it took me that long to realize =
that it was utterly unsuitable for my web app. This roadblock of mine =
might apply to you as well. I had a very clear idea of what I expected =
DB<->web middleware to do, and Rails just plain didn't do it. I spent =
more time figuring out what the current buzzwords were that matched the =
behavior I wanted, pulling down and installing alternatives, and seeing =
if they worked more like I expected they ought. I looked at IOWA, =
SeaSide, Sinatra, Ramaze, and Padrino, among others. I looked at Sequel, =
ActiveRecord, and at least two other ORMs (after figuring out what the =
heck an ORM was in the first place and why I would care).=20

If somebody is young, and doesn't really have a strong background in =
developing for the web, and also doesn't have any kind of pre-existing =
requirements, then there's a fairly good chance that the Ruby-based =
tools will dazzle them. One of the buzzwords that really threw me for a =
while was "legacy." I needed to find an ORM that had strong support for =
legacy databases. Mind you, I am developing a brand-new application, and =
I can create any sort of schema in my database that I want, which is why =
it took me so long to figure out that "legacy" was an important buzzword =
for me. Because the apps I'm building are all about the data.=20

The usual example included with many of these new tools is a =
quick-and-easy blogging site of some kind. Blogs have super-simple data =
structures. My apps have industrial-strength data structures, and there =
is not a single ORM out there that can handle them. (By declaring my db =
schema read-only, I've been able to extend Sequel enough to get the job =
done.)=20

It sounds like Windows7 is serving the same function for you that my =
data structures did for me. It is possible to get everything running on =
W7, I'm sure, but as others have already suggested, it's much more =
problem-prone than the alternatives, so you have to ignore all the =
chirpy happy voices all over the web that promise you can have a web app =
go from concept to launch in a weekend. That happens only under ideal =
circumstances, and one of the requirements is a lack of pre-conceived =
notions, which I think you, like myself, have.=20

"How much non-billable time does a person have to spend on this stuff?" =
I think, all told, I've had to spend about two weeks. I'm still not =
sure, because I've still got one or two really exasperating malfunctions =
that I haven't fixed. Either I have to make Ramaze quit playing around =
with this stupid Mongrel gizmo and hook directly into Apache, so I can =
put muliple websites on the same (*$*)%&@#@ port, by which I mean, port =
EIGHTY!, or Mongrel (or Ramaze, or Innate, or maybe WeBrick, I really =
haven't a clue whose fault this is) has to quit f**king up my redirect =
URLs by sticking :7000 at the end, which contaminates the proxy/reverse =
proxy URL rewrites and causes the redirect to fail. Grrrrrrr!=20

However, with all that being said, I definitely feel that I'm going to =
save more than two weeks of programming time in the long run. (Whether I =
can sneak the savings into a billable form is another matter.) I can now =
create and edit web pages that contain forms for editing data from my =
database with great ease, even when the form contains multiple rows of =
data that are connected to the main table data via a many-to-many =
linking table, all of which have to be editable on the same form and =
written back to the database. Even though I've had to write my own code =
to do some of the functions that used to be handled by my old middleware =
tools, I still expect the total amount of code I'll have to write to be =
about half of what it would have been with the old tool.=20

In short, yea, at least for me, it was definitely worth it, even though =
the amount of time it took to get the tools actually operational was =
far, far longer than I'd been led to believe.=20

By the way, I did eventually post a message not unlike your first one, =
and I also got back a lot of useful suggestions and advice despite the =
fact that I probably should have gotten kicked in the shins instead. =
{grin} I would suggest you might want to try what in the end really =
worked for me: Describe what you want to DO, not which tools you've =
tried to get to work, and let people suggest potential tools for you to =
consider. (There are, for example, at least three different Ruby-to-
Postgres libraries, one of which is extinct, but not obviously so. It =
sounds like one of the MySQL gems is similar.) There might be an =
all-in-one installer available, or somebody might describe some simple =
virtualization scheme that you could use to get something up and running =
well enough to evaluate it. If you like it, then recreating it under =
Windows7 might be easier, since you'd at least know how it was supposed =
to look if it's working correctly.=20

Tap the hive mind, and save yourself a lot of frustration. Because I =
absolutely concur that there's a LOT of frustration lying in wait for =
the unsuspecting developer.=20
Charles Roper
2010-10-06 16:30:13 UTC
Permalink
Now, everything comes in pieces, and you have to snap it together yourself, and there's just so much more opportunity for things to not fit together correctly.
Rails originally started out as being (very) opinionated (not so much
nowadays, esp. since v3). You used the stack it provided and built
your app in a certain way. That has changed quite a bit now, but much
of it still applies. That's where the thing about 'legacy' databases
comes from. If you're using a database that doesn't fit the Rails
mould it's most likely to be an old, legacy database. If you
intentionally don't use the Rails mould and create a db in *your*
mould, then there's not a lot of point in using Rails because its
strength is in its opionionatedness and it's probably worth
investigating the alternatives.

This interview with DHH gives some insight into this thinking:

http://www.oreillynet.com/network/2005/08/30/ruby-rails-david-heinemeier-hansson.html

Charles
Ed Reed
2010-10-06 21:14:27 UTC
Permalink
Thanks for the extensive reply Dave. I certainly appreciate it.

I spent a lot of time last night looking at all the pieces that need to
be 'snapped together' to get, what I think should be, a simple db cgi
app to work and I just can't figure out how it can be worth it. I
appreciate your's and everyone else's sentiments but I need to create a
working project that is stable and supportable. It needs to work with
databases where a Ruby api will never exist for them, because they're
not mainstream enough. I would like to test it against other more
mainstream dbs though, so a project like dbi with odbc seems
appropriate. But, I also need to be sure, when the client comes to me
after only six months needing an update, that one of those 'snapins'
isn't gonna be considered a 'dead project'. I don't see how people can
work like this. It's unacceptable to say that Windows is a difficult
development platform. Over 90% of all businesses are small businesses
and most small businesses don't have the budget or knowledge to setup
and maintain a linux backend. I don't wanna get into an OS war here,
there's no point to it. Small businesses use Windows, period. 90% is a
number that is too huge to ignore.

I will do as you suggest and explain what I'm trying to do instead of
talking about what I've done and maybe I'll get some suggestions. At
this moment though, I think Ruby and I are a 'dead project'

Thanks again to everyone.
--
Posted via http://www.ruby-forum.com/.
Brian Candler
2010-10-07 07:56:47 UTC
Permalink
Post by Ed Reed
I spent a lot of time last night looking at all the pieces that need to
be 'snapped together' to get, what I think should be, a simple db cgi
app to work and I just can't figure out how it can be worth it. I
appreciate your's and everyone else's sentiments but I need to create a
working project that is stable and supportable.
That, to me, is the *benefit* of going with the Rails opinionated
design. Any other Rails developer who comes along to your project in 6
months time will have a head-start on how your code is structured. But I
guess you could say the same about any application design environment.
Post by Ed Reed
It needs to work with
databases where a Ruby api will never exist for them, because they're
not mainstream enough.
But they do have an ODBC connector? Then I'd have thought that ruby-odbc
should work, and there's a standard plugin
(activerecord-sqlserver-adapter)
Post by Ed Reed
It's unacceptable to say that Windows is a difficult
development platform.
Well I'm sorry, but it is. It's a total pain. Stuff which is just a
"./configure && make" away in Linux is an absolute nightmare to get
working under Windows.
Post by Ed Reed
Over 90% of all businesses are small businesses
and most small businesses don't have the budget or knowledge to setup
and maintain a linux backend. I don't wanna get into an OS war here,
there's no point to it. Small businesses use Windows, period. 90% is a
number that is too huge to ignore.
Then you are free to find a tool which is more suitable to your
environment - MS Access perhaps?

Nobody on this list is really going to give you a hard sell on Rails,
because this is not a Rails mailing list anyway :-) And finding a
technology which you are comfortable with is obviously a choice which
depends on your particular circumstances.

Regards,

Brian.
--
Posted via http://www.ruby-forum.com/.
Ed Reed
2010-10-08 19:09:03 UTC
Permalink
Post by Brian Candler
Then you are free to find a tool which is more suitable to your
environment - MS Access perhaps?
Come on, you know that wasn't my point. Name me five of the top DBs that
don't have Windows as a primary platform. If the services run there why
should it not be expected that the development tools run there as well?
--
Posted via http://www.ruby-forum.com/.
Phillip Gawlowski
2010-10-08 19:30:48 UTC
Permalink
Post by Ed Reed
Post by Brian Candler
Then you are free to find a tool which is more suitable to your
environment - MS Access perhaps?
Come on, you know that wasn't my point. Name me five of the top DBs that
don't have Windows as a primary platform.
Postgres, Oracle, DB2, MySQL, Informix, SAP ERP.
--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
Ed Reed
2010-10-08 22:38:47 UTC
Permalink
Post by Phillip Gawlowski
Postgres, Oracle, DB2, MySQL, Informix, SAP ERP.
There's no need to be a smart ass, you knew exactly what I was talking
about.

From their own websites...

Postgres
"Binary packages
Pre-built binary packages are available for a number of different
operating systems: FreeBSD · Linux · Mac OS X · Solaris · Windows"

Oracle
"(11.2.0.1.0)
Download Microsoft Windows (32-bit) File 1, File 2 (2GB) See All
Download Microsoft Windows (x64) File 1, File 2 (2GB) See All
Download Linux x86 File 1, File 2 (2GB) See All
Download Linux x86-64 File 1, File 2 (2GB) See All
Download Solaris (SPARC) (64-bit) File 1, File 2 (2GB) See All
Download Solaris (x86-64) File 1, File 2 (2GB) See All
Download HP-UX Itanium File 1, File 2 (2GB) See All
Download HP-UX PA-RISC (64-bit) File 1, File 2 (2GB) See All
Download AIX (PPC64) File 1, File 2 (2GB) See All"

DB2
"Software DB2 for Linux, UNIX, and Windows"

MySQL
"MySQL Community Server 5.1.51
Select Platform:

Windows (x86, 32-bit), MSI Installer 5.1.51 105.9M
Download
(mysql-5.1.51-win32.msi) MD5: 1eccd54da2caa09dbf4d65e3012c23df
Windows (x86, 32-bit), MSI Installer
Essentials - Recommended"

Informix
"Operating systems supported: AIX, HP Unix, Linux, Macintosh, Sun
Solaris, Windows"
--
Posted via http://www.ruby-forum.com/.
Phillip Gawlowski
2010-10-09 15:58:30 UTC
Permalink
Post by Ed Reed
Post by Phillip Gawlowski
Postgres, Oracle, DB2, MySQL, Informix, SAP ERP.
There's no need to be a smart ass, you knew exactly what I was talking
about.
From their own websites...
[snip list o'vendors]

You should also check the programming language bindings these vendors
supply. You'll find that Ruby is lacking in pretty much all of them
(Oracle provided a package for Ruby, but I don't think it's still
supported; it's hard to find, anyway), leaving it to the Ruby
community to provide support. And since the Ruby community is
predominantly *NIX oriented, you can't expect Windows support
automatically.

If Ruby doesn't fit within your set of constraints (Win7 +ODBC + Web),
move on, and pick something that does (e.g. Win7 + ASP.NET + SQL
Server Express).
--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
Charles Roper
2010-10-09 18:05:00 UTC
Permalink
Post by Phillip Gawlowski
If Ruby doesn't fit within your set of constraints (Win7 +ODBC + Web),
It would be interesting to know how Python fares with these
constraints - it's been around a bit longer and seems to have better
Windows support.

Charles
Stuart Ellis
2010-10-10 09:00:37 UTC
Permalink
Post by Phillip Gawlowski
=20
Post by Phillip Gawlowski
Postgres, Oracle, DB2, MySQL, Informix, SAP ERP.
=20
There's no need to be a smart ass, you knew exactly what I was =
talking
Post by Phillip Gawlowski
about.
=20
=46rom their own websites...
[snip list o'vendors]
=20
You should also check the programming language bindings these vendors
supply. You'll find that Ruby is lacking in pretty much all of them
(Oracle provided a package for Ruby, but I don't think it's still
supported; it's hard to find, anyway), leaving it to the Ruby
community to provide support. And since the Ruby community is
predominantly *NIX oriented, you can't expect Windows support
automatically.
FWIW, this is one of the reasons that I recently switched to using JRuby =
as my default Ruby implementation - it lets you use the standard JDBC =
drivers from proprietary database vendors with a Ruby database library =
like Sequel or Active Record. Setup is painless and JRuby has excellent =
support for Windows. I'm now a big fan.

---
Stuart Ellis
***@stuartellis.eu
David
2010-10-10 16:48:30 UTC
Permalink
[Note: parts of this message were removed to make it a legal post.]

I was going to suggest to the Windows 7 Developer, that using a virtual box
OSE on top Windows 7, with a Linux Guest OS.

Install Ruby and MYSQL on that, happy days.
Post by Phillip Gawlowski
Post by Ed Reed
Post by Phillip Gawlowski
Postgres, Oracle, DB2, MySQL, Informix, SAP ERP.
There's no need to be a smart ass, you knew exactly what I was talking
about.
From their own websites...
[snip list o'vendors]
You should also check the programming language bindings these vendors
supply. You'll find that Ruby is lacking in pretty much all of them
(Oracle provided a package for Ruby, but I don't think it's still
supported; it's hard to find, anyway), leaving it to the Ruby
community to provide support. And since the Ruby community is
predominantly *NIX oriented, you can't expect Windows support
automatically.
FWIW, this is one of the reasons that I recently switched to using JRuby as
my default Ruby implementation - it lets you use the standard JDBC drivers
from proprietary database vendors with a Ruby database library like Sequel
or Active Record. Setup is painless and JRuby has excellent support for
Windows. I'm now a big fan.
---
Stuart Ellis
--
+-------------------------------------------------------------------------------------
David

I have no doubt that in reality the future will be vastly more surprising
than anything I can imagine. Now my own suspicion is that the Universe is
not only queerer than we suppose, but queerer than we can suppose.
- J.B.S. Haldane
+-------------------------------------------------------------------------------------
Phillip Gawlowski
2010-10-10 17:02:23 UTC
Permalink
Post by David
I was going to suggest to the Windows 7 Developer, that using a virtual box
OSE on top Windows 7, with a Linux Guest OS.
Install Ruby and MYSQL on that, happy days.
Since the client wants a Rails app running on Windows, that won't quite work. ;)
--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
Matthew K. Williams
2010-10-11 15:05:37 UTC
Permalink
Post by Phillip Gawlowski
Post by David
I was going to suggest to the Windows 7 Developer, that using a virtual box
OSE on top Windows 7, with a Linux Guest OS.
Install Ruby and MYSQL on that, happy days.
Since the client wants a Rails app running on Windows, that won't quite work. ;)
--
One thing I've not seen anyone mention as yet is using jruby for the ruby
interpreter. I've had decent luck using it under windows. And the jdbc
connectors are pretty good, too.

Matt
Chuck Remes
2010-10-11 15:16:31 UTC
Permalink
Post by Phillip Gawlowski
Post by David
I was going to suggest to the Windows 7 Developer, that using a virtual box
OSE on top Windows 7, with a Linux Guest OS.
Install Ruby and MYSQL on that, happy days.
Since the client wants a Rails app running on Windows, that won't quite work. ;)
--
One thing I've not seen anyone mention as yet is using jruby for the ruby interpreter. I've had decent luck using it under windows. And the jdbc connectors are pretty good, too.
I use JRuby almost exclusively under Windows. One of the great benefits is that it supports 64-bit runtimes whereas MRI does not yet have a 64-bit runtime for Windows.

Also, the WIN32OLE stuff is coming to JRuby soon. Check out the projects on github:

http://github.com/enebo/jacob

and

http://github.com/enebo/jrwin32ole

cr
Jeremy Bopp
2010-10-08 20:10:15 UTC
Permalink
Post by Ed Reed
Post by Brian Candler
Then you are free to find a tool which is more suitable to your
environment - MS Access perhaps?
Come on, you know that wasn't my point. Name me five of the top DBs that
don't have Windows as a primary platform. If the services run there why
should it not be expected that the development tools run there as well?
The development tools provided by the DB vendors *do* work on the
platforms they support, including Windows. However, those particular
development tools do *not* include Ruby, Rails, or the gems that
interface with those DBs. Is there something that lead you to believe
otherwise?

-Jeremy
Ed Reed
2010-10-08 22:46:14 UTC
Permalink
Post by Jeremy Bopp
The development tools provided by the DB vendors *do* work on the
platforms they support, including Windows. However, those particular
development tools do *not* include Ruby, Rails, or the gems that
interface with those DBs. Is there something that lead you to believe
otherwise?
It's useless to argue about semantics on this issue in a forum like
this. I'm talking about the thirty thousand foot view of things. If a db
runs on a particular platform and a development tool runs on a the same
platform. I should be able to develop something with that tool and have
it run on that platform.

Don't start a flame war because you want to pick at a point. It goes
back to what I said earlier, 90% is a number that is too big to ignore.
You can shout all you want about the 10% and you may be absolutely right
about the 10% but it doesn't change the numbers.
--
Posted via http://www.ruby-forum.com/.
Jeremy Bopp
2010-10-08 22:54:13 UTC
Permalink
Post by Ed Reed
Post by Jeremy Bopp
The development tools provided by the DB vendors *do* work on the
platforms they support, including Windows. However, those particular
development tools do *not* include Ruby, Rails, or the gems that
interface with those DBs. Is there something that lead you to believe
otherwise?
It's useless to argue about semantics on this issue in a forum like
this. I'm talking about the thirty thousand foot view of things. If a db
runs on a particular platform and a development tool runs on a the same
platform. I should be able to develop something with that tool and have
it run on that platform.
Don't start a flame war because you want to pick at a point. It goes
back to what I said earlier, 90% is a number that is too big to ignore.
You can shout all you want about the 10% and you may be absolutely right
about the 10% but it doesn't change the numbers.
I'm seriously not trying to pick a fight. Honest. I'm really curious
what lead you to believe that there is a complete Ruby solution for
these DBs and Windows that had any promise of long term support. You
seem to have approached this whole effort with the expectation that
there is a large vendor providing some kind of professional solution
akin to .NET from Microsoft when in fact there is no such beast (at
least not yet).

A 30k foot view of things may lead to misunderstandings by itself but so
can poor or misleading documentation and erroneous Internet memes. If
you can give us an idea of what lead to your misconceptions, maybe we
can try to address those things. That's all I'm saying.

-Jeremy
Charles Roper
2010-10-09 12:27:49 UTC
Permalink
Post by Jeremy Bopp
A 30k foot view of things may lead to misunderstandings by itself but so
can poor or misleading documentation and erroneous Internet memes. =C2=A0=
If
Post by Jeremy Bopp
you can give us an idea of what lead to your misconceptions, maybe we
can try to address those things. =C2=A0That's all I'm saying.
Yeah, Ed does have a point in that creating a web app that runs on
Windows 7 and talks to multiple ODBC data sources is apparently not a
great experience with Ruby. But that does beg the question: who said
it *would* be a great experience? Ruby is a great programming
language, but it is by no means perfect. Lacklustre Windows support
has long been a problem, but this is gradually improving thanks to the
efforts of the open source community. The trouble is, open source is
usually just a bunch of people scratching itches and because the Ruby
community is very *nix based, progress on Windows is often slow. In
only 2007, Luis Lavena took over maintenance of the 1-Click Installer
(now RubyInstaller), and he and the team have made great
transformational strides, but they can't do everything and therein
lies the rub: folk such as Ed come along and try something, get
frustrated, then go away. But the Ruby community *needs* experienced
Windows developers in order to help improve the tools on Windows.

Ed, compare this post:
http://blog.mmediasys.com/2008/03/06/is-windows-a-supported-platform-for-ru=
by-i-guess-not/

to this one:
http://blog.mmediasys.com/2010/09/23/rubyinstaller-what-where-when-1/

Things are getting better, but there's still a long way to go. Ed, if
you do persevere and manage to hook things up, it would be
tremendously helpful if you could share your solution so that others
may benefit. I would certainly find it very useful indeed to be able
to run an internal webapp that connects to multiple ODBC databases on
Windows.

Charles
David Masover
2010-10-08 07:12:40 UTC
Permalink
My current web-app environment is PostgreSQL for the database, Apache &/or
Mongrel &/or WeBrick for the web server (I really don't understand that
part yet). The ODBC driver has been replaced with some postgres libraries
and the pg gem. Tango has been replaced with Ramaze&Sequel&(mumble).
"Mumble" was originally HAML, but in the end I just scrapped the entire
idea of using a templating engine because I couldn't stand the
limitations, so now (mumble) is some custom code I wrote for myself.
What limitations? I'm curious.

And, did you try Erector, or something similar? I prefer Haml, but if I was
finding it "limiting", I think that's where I'd go next.
I then spent yet another whole day trying to get Rails to work. I'd heard
such glowing praise for Rails that it took me that long to realize that it
was utterly unsuitable for my web app.
Again, I'm curious -- both about what the app was, and when this was. Rails
has come a long way.
I looked at Sequel,
ActiveRecord, and at least two other ORMs (after figuring out what the
heck an ORM was in the first place and why I would care).
DataMapper?
Either I have to make Ramaze quit playing around with this
stupid Mongrel gizmo and hook directly into Apache,
Trivial -- look into Passenger. But I'm trying to answer the "what, not how"
questions below.
so I can put muliple
..why?

Assuming this is a requirement, the most flexible approach seems to be some
sort of reverse proxy. Apache can do it, nginx makes it simple and
lightweight, fairly trivial to just say "Any URL that starts with this gets
forwarded to this port on localhost."

The cool part is that you're then no longer tied to any one webserver, or even
any one machine.

The annoying part is that it's maybe more work than it should be to get a dev
environment setup.
or
Mongrel (or Ramaze, or Innate, or maybe WeBrick, I really haven't a clue
whose fault this is) has to quit f**king up my redirect URLs by sticking
:7000 at the end, which contaminates the proxy/reverse proxy URL rewrites
Probably Ramaze, or you. Generate relative URLs, or absolute URLs that start
with / instead of a domain, or hardcode the domain instead of detecting the
port. I don't know enough about Ramaze to know how difficult this is.

It would probably be possible to fix this at a lower level, like Rack or the
webserver itself, to fool Ramaze into thinking it's running somewhere else,
but you want the freedom to be able to tell Ramaze what kind of URLs it should
generate.
Dave Howell
2010-10-13 01:51:21 UTC
Permalink
Post by David Masover
Post by Dave Howell
My current web-app environment is PostgreSQL for the database, Apache =
&/or
Post by David Masover
Post by Dave Howell
Mongrel &/or WeBrick for the web server (I really don't understand =
that
Post by David Masover
Post by Dave Howell
part yet). The ODBC driver has been replaced with some postgres =
libraries
Post by David Masover
Post by Dave Howell
and the pg gem. Tango has been replaced with Ramaze&Sequel&(mumble).
"Mumble" was originally HAML, but in the end I just scrapped the =
entire
Post by David Masover
Post by Dave Howell
idea of using a templating engine because I couldn't stand the
limitations, so now (mumble) is some custom code I wrote for myself.
=20
What limitations? I'm curious.
I think mostly I would go to the template, and then discover that I'd =
need some logic to get it to come out right, so I'd mix that in (which =
really clutters things up), and then I'd realize I needed to loop it, =
and so I'd move that whole chunk back to the controller. The =
deal-breaker came when I found it was apparently impossible to emit HAML =
*from the controller* and have it processed. If I move this chunk of =
template back to the controller because of the need to change the output =
based on the data, then I had to emit HTML, then convince HAML not to =
escape it. So I just went back to HTML in the first place, and cut down =
on the number of languages I had to deal with.=20
Post by David Masover
And, did you try Erector, or something similar? I prefer Haml, but if =
I was=20
Post by David Masover
finding it "limiting", I think that's where I'd go next.
I didn't find Erector when I was looking. It was mentioned to me =
recently, and look at first glance rather a lot like what I built for =
myself, so I intend to give it a very close look sometime soon.=20
Post by David Masover
Post by Dave Howell
I then spent yet another whole day trying to get Rails to work. I'd =
heard
Post by David Masover
Post by Dave Howell
such glowing praise for Rails that it took me that long to realize =
that it
Post by David Masover
Post by Dave Howell
was utterly unsuitable for my web app.
=20
Again, I'm curious -- both about what the app was, and when this was. =
Rails=20
Post by David Masover
has come a long way.
It's a program for a pharmaceutical company to track their products, =
processing, and inventory. My PostgreSQL schema uses a custom data type =
('percentage' which is a numeric(5,2) that cannot be set above 100.00 or =
below 0.00), uses UUIDs for the primary keys of most tables, and takes =
advantage of PostgreSQL's "array" datatype to let me eliminate five or =
six linking tables, to just name a couple things off the top of my head =
that were completely un-create-able from within Rails and ActiveRecord.=20=


I had to add code to Sequel to support UUIDs and arrays as well, but at =
least I could figure out HOW.=20
Post by David Masover
Post by Dave Howell
I looked at Sequel,
ActiveRecord, and at least two other ORMs (after figuring out what =
the
Post by David Masover
Post by Dave Howell
heck an ORM was in the first place and why I would care).
=20
DataMapper?
That sounds familar. Yea, I think so.=20
Post by David Masover
Post by Dave Howell
Either I have to make Ramaze quit playing around with this
stupid Mongrel gizmo and hook directly into Apache,
=20
Trivial -- look into Passenger. But I'm trying to answer the "what, =
not how"=20
Post by David Masover
questions below.
=20
Post by Dave Howell
so I can put muliple
=20
...why?
=20
Assuming this is a requirement, the most flexible approach seems to be =
some=20
Post by David Masover
sort of reverse proxy. Apache can do it, nginx makes it simple and=20
lightweight, fairly trivial to just say "Any URL that starts with this =
gets=20
Post by David Masover
forwarded to this port on localhost."
You'd think so. I need it because I *am* using a reverse proxy. However, =
the redirect _attaches the port number_, which the reverse proxy =
commands of Apache do not strip back off. The primary webserver is =
running Apache, but this site is on a different machine, and the main =
machine redirects traffic to it. So from the outside, they go to =
'specific domain,' which goes to the primary webserver, port 80, with =
the target domain in the header, which reverseproxies it to the other =
machine on port 7000 (for the production site) or 7010 (for the =
demo/test site). And then the redirect occurs, and the client's web =
browser is now trying to get to =
"http://domain.com:7000/path/to/whatever" which obviously fails.=20

I've tried adding URL rewrite rules in apache to fix them, but the =
interaction with the reverse proxy has utterly confounded me.=20
=20=
David Masover
2010-10-13 21:46:10 UTC
Permalink
Post by David Masover
What limitations? I'm curious.
I think mostly I would go to the template, and then discover that I'd need
some logic to get it to come out right, so I'd mix that in (which really
clutters things up), and then I'd realize I needed to loop it, and so I'd
move that whole chunk back to the controller.
Except Haml has looping constructs. There's also a pretty neat idiom where you
call a partial from a loop, so you keep your templates small. Unless your
loops are particularly bizarre, you'd still be looping over something that
came from your controller, so I don't think it's too much code in your
templates. Even if it was, I certainly don't see how abandoning the idea of
separating logic from presentation wholesale is better.
The deal-breaker came when I
found it was apparently impossible to emit HAML *from the controller* and
have it processed.
I'm pretty sure that's not true, though it's probably a bad idea and the code
would likely be ugly.
Post by David Masover
And, did you try Erector, or something similar? I prefer Haml, but if I
was finding it "limiting", I think that's where I'd go next.
I didn't find Erector when I was looking. It was mentioned to me recently,
and look at first glance rather a lot like what I built for myself, so I
intend to give it a very close look sometime soon.
It's basically a next-generation Markaby, and I'm guessing that existed when
you were looking. Ah, well...
Post by David Masover
Post by Dave Howell
I then spent yet another whole day trying to get Rails to work. I'd
heard such glowing praise for Rails that it took me that long to
realize that it was utterly unsuitable for my web app.
Again, I'm curious -- both about what the app was, and when this was.
Rails has come a long way.
It's a program for a pharmaceutical company to track their products,
processing, and inventory. My PostgreSQL schema uses a custom data type
('percentage' which is a numeric(5,2) that cannot be set above 100.00 or
below 0.00),
Huh. DataMapper does support custom, user-defined types, though I'm not sure
how easy it is to do that with an existing adapter. (To give you an idea,
there is currently a working DataMapper adapter for Google App Engine.)
uses UUIDs for the primary keys of most tables,
Should work. I'm fairly sure I did this with ActiveRecord, too, at one point,
though i don't remember how.
and takes
advantage of PostgreSQL's "array" datatype to let me eliminate five or six
linking tables,
App Engine also has a list type. Support for it is currently workable but not
great, but I do have plans to implement associations through arrays of ids at
some point, for example.
Post by David Masover
Assuming this is a requirement, the most flexible approach seems to be
some sort of reverse proxy. Apache can do it, nginx makes it simple and
lightweight, fairly trivial to just say "Any URL that starts with this
gets forwarded to this port on localhost."
You'd think so. I need it because I *am* using a reverse proxy. However,
the redirect _attaches the port number_,
Yeah, it shouldn't do that. Either Rails doesn't, or nginx does strip that
(unlikely), because I've hosted production Rails apps in exactly this
environment -- nginx listening on example.com, forwarding to multiple Mongrels
on various ports, not necessarily on the same machine.

So, probably somewhere in Ramaze.
I've tried adding URL rewrite rules in apache to fix them, but the
interaction with the reverse proxy has utterly confounded me.
I don't remember how, but I know that one thing Apache's rewrite rules can do
is pipe URLs to an external program. It's a trivial protocol (it sends the URL
on stdin, you give it the new URL on stdout), and that external program is a
long-running one, so you could even write that in Ruby.

But it seems like it should be much easier to fix this at the source.
Dave Howell
2010-10-14 00:03:04 UTC
Permalink
=20
The deal-breaker came when I
found it was apparently impossible to emit HAML *from the controller* =
and
have it processed.
=20
I'm pretty sure that's not true, though it's probably a bad idea and =
the code=20
would likely be ugly.
It might be possible, but I spent three or four hours trying, and =
failed. More about this in a following paragraph.
I certainly don't see how abandoning the idea of=20
separating logic from presentation wholesale is better.
Neither did the people on the Sequel list. But I should say that I =
didn't abandon separating logic from presentation. It was my MODEL that =
ended up having to handle most of the presentation that kept climbing =
out of Haml.=20
It's a program for a pharmaceutical company to track their products,
processing, and inventory. My PostgreSQL schema uses a custom data =
type
('percentage' which is a numeric(5,2) that cannot be set above 100.00 =
or
below 0.00),
=20
Huh. DataMapper does support custom, user-defined types, though I'm =
not sure=20
how easy it is to do that with an existing adapter. (To give you an =
idea,=20
there is currently a working DataMapper adapter for Google App =
Engine.)

I found all kinds of indications that even ActiveRecord *could* do what =
I wanted. But in the end, whether or not something is *possible* is =
completely irrelevant in the face of "can *I* make it do that in a =
reasonable amount of time?"=20

IIRC, DataMapper and Sequel both seemed to have fairly similar =
capabilities based on various people's descriptions, and I think both of =
them were recommended to me a couple of times. Sequel's documentation =
kicks titanic ass, though: far and away the best I've ever gotten with =
any Ruby-related thingamabob. Well written and well organized RDoc-y =
parts, AND extensive walk-throughs, examples, and discussions, all =
installed right on my system, plus a developer whom I've seen easily =
answer questions that made my eyes cross.=20

HAML's documentation *looked* really good at first, but that's because =
it's good at telling you what it thinks you should know. It was =
completely silent on how to make it process the contents of a variable =
as HAML, or to otherwise get it inserted *before* interpretation. Nor =
could whichever list I asked on provide a workable answer. (feature I =
cannot find or use) =3D=3D !(feature)
You'd think so. I need it because I *am* using a reverse proxy. =
However,
the redirect _attaches the port number_,
=20
Yeah, it shouldn't do that. Either Rails doesn't, or nginx does strip =
that=20
(unlikely), because I've hosted production Rails apps in exactly this=20=
environment -- nginx listening on example.com, forwarding to multiple =
Mongrels=20
on various ports, not necessarily on the same machine.
=20
So, probably somewhere in Ramaze.
I think it's probably in Innate, but I'm not really clear on how Innate =
and Ramaze are related. Alas, Ramaze's docs are rather scattered and not =
entirely up to date.
David Masover
2010-10-15 06:18:32 UTC
Permalink
Post by David Masover
I certainly don't see how abandoning the idea of
separating logic from presentation wholesale is better.
Neither did the people on the Sequel list. But I should say that I didn't
abandon separating logic from presentation. It was my MODEL that ended up
having to handle most of the presentation that kept climbing out of Haml.
To be honest, that sounds even worse. I push most of the logic back into the
model and most of the presentation into the view, leaving controllers mostly
for routing requests and authentication.
Post by David Masover
Post by Dave Howell
It's a program for a pharmaceutical company to track their products,
processing, and inventory. My PostgreSQL schema uses a custom data type
('percentage' which is a numeric(5,2) that cannot be set above 100.00 or
below 0.00),
Huh. DataMapper does support custom, user-defined types, though I'm not
sure how easy it is to do that with an existing adapter. (To give you an
idea, there is currently a working DataMapper adapter for Google App
Engine.)
I found all kinds of indications that even ActiveRecord *could* do what I
wanted. But in the end, whether or not something is *possible* is
completely irrelevant in the face of "can *I* make it do that in a
reasonable amount of time?"
I absolutely agree. However...
Sequel's documentation kicks titanic
ass, though: far and away the best I've ever gotten with any Ruby-related
thingamabob. Well written and well organized RDoc-y parts, AND extensive
walk-throughs, examples, and discussions, all installed right on my
system, plus a developer whom I've seen easily answer questions that made
my eyes cross.
In terms of developers, I've seen the same with DataMapper...
HAML's documentation *looked* really good at first, but that's because it's
good at telling you what it thinks you should know. It was completely
silent on how to make it process the contents of a variable as HAML, or to
otherwise get it inserted *before* interpretation.
So, I hate to say it, but...

These things are open source. The source is open. More than that, Haml has a
decent test suite, which is always a good place to look when you want to know
how to use some code. It took me about three minutes to find this:

http://github.com/nex3/haml/blob/master/test/haml/template_test.rb

In particular, this line:

Haml::Engine.new(File.read(File.join(TemplateTest::TEMPLATE_PATH,
"_#{name}.haml"))).render(self, locals)

Seems to me that you'd just replace the "File.read" part with the source of
whatever you're trying to render. Note that this will likely be _much_ more
efficient if you can keep the Engine object around, and that's true for any
template system, which is probably why it makes more sense for you to take
whatever you were going to do here and put it in a partial...

Now, granted, that should only ever be a stopgap solution. After getting that
working, the immediate next thing would be to bother the list with, "Hey, I
got this working, is this likely to continue to work? If not, how can I get it
working?"

But the point is, while good docs are a good thing, I think working and
readable code is at least as important. If the docs are almost completely
comprehensive, but the code is shitty, I'm screwed as soon as I manage to ask
a question the docs can't answer. If the docs are a good starting point, but
the code is solid, I have confidence that I can answer _any_ question. If the
docs are absolutely worthless, I can't even get started.

So it seems to me like the ideal amount of documentation is enough to get
started, and more only if people have time, or where the code is particularly
unclear.

By the way, I generally only allow this excuse for libraries. If I'm
programming in Ruby, I'd better be able to read Ruby code. The same is NOT
true if I'm a user -- I should NEVER have to dig into the code of nginx.
Dave Howell
2010-10-15 23:57:42 UTC
Permalink
Post by David Masover
So, I hate to say it, but...
=20
These things are open source. The source is open. More than that, Haml =
has a=20
Post by David Masover
decent test suite, which is always a good place to look when you want =
to know=20
Post by David Masover
how to use some code.=20
I don't know why you hate to say that.=20
Post by David Masover
But the point is, while good docs are a good thing, I think working =
and=20
Post by David Masover
readable code is at least as important.
I would agree with that.=20

But reading the code fundamentally tells you WHAT the code does. I look =
to the documentation to find out WHY?

There was nothing in the Sequel documentation that told me how I could =
get it to start identifying UUID codes as "type uuid" instead of =
pretending they were strings. But the code was fairly readable, and =
after following a few class definitions back up into the code, I =
eventually found a section that had a case statement regarding db types =
and Ruby types. and I figured out what to add to get it to give me =
UUIDs. There were still a few parts where I was scratching my head and =
going "What does this part do?"

It's quite possible that the answer on how to get Haml to interpret =
stuff was staring me in the face at some point, and I missed it. I'm =
afraid that doesn't change my point at all.=20

"I couldn't make the Frobulator fricassee."
"Oh, the Frobulator can definitely fricassee."
"I couldn't find any information about it in the documentation."
"Well, it's not in the documentation as such, unless you already know =
that fricassee is just a special case of fricolating a tri-fold array. =
But it's easy to find in the source code."
"I haven't been able to figure out how this code works."

Whether I'm too ignorant to figure out from the source code how to =
fricassee, or the source code's so poorly written that most people can't =
figure it out, or the docs fail to explain it, or it just can't do that =
in the first place, the end result is the same: no fricassee-ing.=20

I could tell pretty early on that my biggest problem with finding a good =
ORM was not that there were very few that were *capable* of doing what I =
wanted, but that very few of the people who'd written the documentation =
were describing their ORM's capabilities from the point of view that I =
had: from the database, instead of from the middleware. I kept finding =
tutorials that would say "or you can edit the blahblah file to work with =
an existing legacy database." However, I couldn't even *get* a blahblah =
file to edit from either Rails or Ramaze, because all the tutorials and =
documentation took it for granted that I was interested in making a new =
web site from scratch, and didn't really care all that much about the =
details of data storage.=20
Sinatra (or rather, the ORM that came bundled with Sinatra) had =
a tool that was supposed to build me a class/object ORM file from my =
schema, but it couldn't handle UUID primary keys, so it only created =
about 33% of the material I needed.
I then had to decide if it would be more efficient to just walk =
through the whole tutorial, learning about scaffolding and migrations, =
knowing that I would not have any use whatsoever for knowledge related =
to migrations, until I finally knew enough about the whole system that I =
would have the background needed to understand the code well enough to =
be able to figure out how to make it do what I wanted, OR would it be a =
better use of my time to start over with some other ORM or library or =
whatever, where I would be able to get started sooner by being able to =
take better advantage of my existing knowledge? I chose the latter =
route, although I would not be able to prove to somebody if it was the =
better choice or not.=20

The better I get at reading other people's Ruby code, the less I'll need =
to rely on good documentation.=20
There is a nebulous point of diminishing returns, where "better" (aka =
"more) documentation becomes a waste of time; there is a certain amount =
of knowledge that the user/programmer can be expected to know. For =
example, the Sequel documentation takes it for granted that I am totally =
familiar with SQL; most of the docs explain what the code does in terms =
of the equivalent SQL code. Should there be even more docs for people =
trying to use Sequel who've never worked directly with a SQL database =
before? It *would* make Sequel even more accessible to more programmers, =
but it's probably not worth the effort it would take for somebody to =
create that much more documentation.=20

Certainly my inability to get Haml to work for me does not mean that its =
documentation sucks, or that it sucks. It just didn't work for me.=20
Post by David Masover
=20
http://github.com/nex3/haml/blob/master/test/haml/template_test.rb
=20
=20
Haml::Engine.new(File.read(File.join(TemplateTest::TEMPLATE_PATH,=20
"_#{name}.haml"))).render(self, locals)
=20
Seems to me that you'd just replace the "File.read" part with the =
source of=20
Post by David Masover
whatever you're trying to render. Note that this will likely be _much_ =
more=20
Post by David Masover
efficient if you can keep the Engine object around, and that's true =
for any=20
Post by David Masover
template system, which is probably why it makes more sense for you to =
take=20
Post by David Masover
whatever you were going to do here and put it in a partial...
Honestly, I have no idea what you just said. I certainly don't see a =
clear path between a code fragment in a test suite to, I guess, =
embedding "Haml::Engine.new(@varWithMyHamlCodeInIt)" inside a Haml =
template. If you do, please do NOT tell me. I'm not using Haml, and at =
this point can't imagine any benefit I could derive that would pay back =
the cost of switching my existing code base over to it.=20

But this, in the end, is all nit-picky detail. My original discussion =
was all about how the current cacophony of Ruby-based middleware was =
actually quite cool and powerful, but that the original poster's to make =
something that is so often described as "really easy" to work at all was =
not some giant Ruby conspiracy or a massive delusion on our part, but =
reflected the fact that, like myself, his background and knowledge base =
were not the assumed default, and I believe that this was one of the =
reasons why he found the whole process so unexpectedly unproductive.=20
Xavier Noria
2010-10-16 01:14:41 UTC
Permalink
On Sat, Oct 16, 2010 at 1:57 AM, Dave Howell
The better I get at reading other people's Ruby code, the less I'll need to rely on good documentation.
Reading source code is good. But in order to use something you
shouldn't need to reverse engineer an implementation, that's a waste
of time in my view. It might be equivalent for small libs, but
generally speaking it is better that you get the stuff digested, and
presented as only the experience and motivations of the author can do.

If you pick AWDwR you have a very balanced perspective on everything
Rails in a few hours of reading. You have a teacher that has prepared
the material properly. If you want to get the same knowledge by
yourself reverse engineering Rails, good luck with that.
Josh Cheek
2010-10-16 10:34:14 UTC
Permalink
[Note: parts of this message were removed to make it a legal post.]
Post by Xavier Noria
If you pick AWDwR you have a very balanced perspective on everything
Rails in a few hours of reading. You have a teacher that has prepared
the material properly. If you want to get the same knowledge by
yourself reverse engineering Rails, good luck with that.
Though, if you're new to web development, then your background and knowledge
base are not the assumed defaults, and AWDWR will be, as Dave Howell said,
an unexpectedly unproductive experience.

If you got anything out of "a few hours of reading", than I am envious. I
spent months reading it, and got almost nothing out of it. To be fair, I had
no prior web experience, I had never seen MVC before, had never tested
before, it was my first time using a database, and my Ruby code looked a lot
like my C code.

For someone interested in ActiveRecord, I'd suggest watching the 15 minute
blog (http://media.rubyonrails.org/video/rails_blog_2.mov), finding a bare
bones working AR implementation like this one (
http://www.themomorohoax.com/2009/03/15/activerecord-sqlite-in-memory-db-without-rails),
and then reading the guides.rubyonrails.org section on models, while
iteratively building the bare bones file up to do what you want.
David Masover
2010-10-16 15:45:28 UTC
Permalink
Post by Dave Howell
Post by David Masover
So, I hate to say it, but...
=20
These things are open source. The source is open. More than that, Haml
has a decent test suite, which is always a good place to look when you
want to know how to use some code.
=20
I don't know why you hate to say that.
Because in a way, it's admitting that the documentation isn't sufficient, a=
nd=20
it's also implying that you _should_ dig into the source code, that this wo=
uld=20
be a perfectly normal thing to do.

That's workable, but certainly not ideal. I hate to say it because I don't=
=20
think people should have to dig into source code to get stuff done -- but i=
t=20
is nice in that you _can_ do that.
Post by Dave Howell
Post by David Masover
But the point is, while good docs are a good thing, I think working and
readable code is at least as important.
=20
I would agree with that.
=20
But reading the code fundamentally tells you WHAT the code does. I look to
the documentation to find out WHY?
I don't see how that's a problem in the Haml case.

Let me put it this way: I'm not a Haml developer, never have been, but that=
=20
took me almost no time to find, and it does make sense to me why it'd be th=
at=20
way. Specifically, it makes sense that you'd have a template object that=20
represents some sort of "compiled" form of a template (or at least parsed=20
form) so that you can efficiently combine that with a given environment (th=
e=20
self and locals arguments), rather than re-parsing the template on every=20
request.

This is far from just a Ruby thing -- in particular, I know that Java's JSP=
=20
files actually get compiled to .class files, just like any other Java sourc=
e.
Post by Dave Howell
There was nothing in the Sequel documentation that told me how I could get
it to start identifying UUID codes as "type uuid" instead of pretending
they were strings. But the code was fairly readable, and after following a
few class definitions back up into the code, I eventually found a section
that had a case statement regarding db types and Ruby types. and I figured
out what to add to get it to give me UUIDs. There were still a few parts
where I was scratching my head and going "What does this part do?"
Right -- and that makes sense. Documentation generally covers the public AP=
I.=20
If you're hacking on the source, you get to keep both pieces when it breaks=
=2E=20
It would be nice if there was better documentation as to where to get start=
ed,=20
for people who do want to play with the source, but ultimately, if you're=20
playing with the source, the goal should either be a fork or a patch, proba=
bly=20
a patch.
Post by Dave Howell
It's quite possible that the answer on how to get Haml to interpret stuff
was staring me in the face at some point, and I missed it. I'm afraid that
doesn't change my point at all.
Actually, it does entirely. It changes your point from "I can't believe Rub=
y=20
won't let me do this," or "I can't believe Ruby makes it so difficult to do=
=20
this," to "I might have missed how to do this." One is a statement about th=
e=20
tool itself -- the language, the framework, or the community behind it -- a=
nd=20
the other is a statement about your ability to interpret it.

It's still a good point, but it's a much more humble one.
Post by Dave Howell
Whether I'm too ignorant to figure out from the source code how to
fricassee, or the source code's so poorly written that most people can't
figure it out, or the docs fail to explain it, or it just can't do that in
the first place, the end result is the same: no fricassee-ing.
However, those are each very different problems with very different solutio=
ns.

If it's just you, then I should do what I can to give you the tools you nee=
d=20
to be able to figure it out yourself, should you need to. I've been trying =
to=20
do that here.

If it's really that poorly written, that absolutely is a good reason to use=
=20
something else.

If the docs don't explain it, and it's something that's supposed to be a=20
feature, the docs should be fixed. However, if the docs don't explain it=20
because it was never designed as a feature in the first place, but is just =
a=20
sort of accidental result of how it's designed, that suggests either it's f=
ine=20
the way it is, or it should be added as an official, public-API feature wit=
h=20
quality documentation.

In particular, documenting something generally makes it part of the public=
=20
API, which means people will be cross if you change it. (If it was document=
ed=20
but not public, it wouldn't be ideal for your purposes, anyway.)

In the last case, the feature should be added if it makes sense.

Now, the ideal steps for you in each of these cases is roughly the same: "I=
s=20
there a way to fricassee? I don't see it in the documentation, and I can't=
=20
figure it out..." or "It looks like I can fricassee this way. Is that likel=
y=20
to change in the future? If so, can I get an official public API for it?"

I don't know if you tried these. If you did and got no response, that's=20
certainly a failing of the community, and I apologize.
Post by Dave Howell
I kept finding
tutorials that would say "or you can edit the blahblah file to work with
an existing legacy database." However, I couldn't even *get* a blahblah
file to edit from either Rails or Ramaze,
Well, but which file? If it was schema.rb, I don't know that it would've=20
helped...
Post by Dave Howell
Sinatra (or rather, the ORM that came bundled
with Sinatra)
Which is that? I wasn't aware Sinatra came bundled with an ORM. I wasn't aw=
are=20
that it made sense for there to be -- seems like you'd just use an ORM=20
directly, without Sinatra knowing or caring about it.
Post by Dave Howell
Should there be even
more docs for people trying to use Sequel who've never worked directly
with a SQL database before? It *would* make Sequel even more accessible to
more programmers, but it's probably not worth the effort it would take for
somebody to create that much more documentation.
Well, in that case, the idea would be to go elsewhere to learn SQL.
Post by Dave Howell
I certainly don't see a clear
path between a code fragment in a test suite to, I guess, embedding
do, please do NOT tell me. I'm not using Haml, and at this point can't
imagine any benefit I could derive that would pay back the cost of
switching my existing code base over to it.
Sorry, I have to, because it's still a one-liner -- the result of that=20
'render' call seems like it'd be a string, like any other you might generat=
e,=20
and Haml doesn't escape strings unless you tell it to. The naive usage woul=
d=20
look like this:

=3D Haml::Engine.new(@var).render(self)

If I had doubts it'd be a string, I'd test it in IRB.
Post by Dave Howell
But this, in the end, is all nit-picky detail.
Maybe, and I apologize if that's all it is. My point for getting into this =
was=20
to find out where the gap between my experience of things truly being easy=
=20
(even when starting out), and your experience of things being difficult or=
=20
impossible.

If it's something I can clear up here, that's helpful. If it's something=20
that's missing from the community as a whole, that's also good to know, too.
Post by Dave Howell
like myself, his background and knowledge base were not the
assumed default, and I believe that this was one of the reasons why he
found the whole process so unexpectedly unproductive.
If that's really all it is, then I hope, if nothing else, I've helped bring=
=20
you closer to that.

=46rom where I'm standing, it looks like the pain point was going against t=
he=20
grain while also being a newbie. That's part of why I've beaten this Haml=20
horse to death -- the answer to the question of "How do I embed Haml code i=
nto=20
my controller?" is generally "Don't do that. Use partials instead." A ton o=
f=20
newbie questions reduce to something similar.

Unfortunately, we can't do that with all of your problems. For example, my=
=20
kneejerk reaction when I see people ask "How do I tie this to a legacy=20
schema?" is "Don't do that, migrate to something sane." But that's obviousl=
y=20
wrong.

=46or what it's worth, as badly as we might need better documentation and=20
tutorials for working with legacy databases, I found it even more frustrati=
ng=20
in the world of Oracle ADF, where an existing, legacy Oracle database=20
(complete with DBA) was assumed, and there was no easy, step-by-step guide =
on=20
getting from zero to a Hello World app.
Dave Howell
2010-10-17 00:09:27 UTC
Permalink
Post by David Masover
=20
Post by Dave Howell
It's quite possible that the answer on how to get Haml to interpret =
stuff
Post by David Masover
Post by Dave Howell
was staring me in the face at some point, and I missed it. I'm afraid =
that
Post by David Masover
Post by Dave Howell
doesn't change my point at all.
=20
Actually, it does entirely.
Only if you ascribe the wrong point in the first place.
Post by David Masover
It changes your point from "I can't believe Ruby=20
won't let me do this," or "I can't believe Ruby makes it so difficult =
to do=20
Post by David Masover
this," to "I might have missed how to do this." One is a statement =
about the=20
Post by David Masover
tool itself -- the language, the framework, or the community behind it =
-- and=20
Post by David Masover
the other is a statement about your ability to interpret it.
=20
It's still a good point, but it's a much more humble one.
array_of_points_in_previous_paragraph.match(mypoint) =3D> nil
Post by David Masover
Post by Dave Howell
Whether I'm too ignorant to figure out from the source code how to
fricassee, or the source code's so poorly written that most people =
can't
Post by David Masover
Post by Dave Howell
figure it out, or the docs fail to explain it, or it just can't do =
that in
Post by David Masover
Post by Dave Howell
the first place, the end result is the same: no fricassee-ing.
=20
However, those are each very different problems with very different =
solutions.
Post by David Masover
=20
If it's just you, then I should do what I can to give you the tools =
you need=20
Post by David Masover
to be able to figure it out yourself, should you need to. I've been =
trying to=20
Post by David Masover
do that here.
And thank you, but really; please don't try and solve the problems that =
I used as examples. They are no longer blocking items, and I do not need =
to fix them.=20

I started with Haml in the first place because the documentation looked =
good. And it *is* good, but I eventually realized that I was having some =
pretty fundamental problems with the *paradigm* on which it's based. =
Because even if "it's just you," the best solution is not necessarily =
"do[ing] what I can to give you the tools you need=20
to be able to figure it out yourself, should you need to." In this case, =
I think a much better solution was to find a tool that worked the way I =
expected it to. Maybe my ultimate choice was *less* capable than the one =
I abandoned. But if its easier for me to use, then for me, the =
replacement will do more, and do it more easily, than the "better" tool =
that does not match well with my existing experience and knowledge. =
Quality of code notwithstanding. Documentation notwithstanding.=20
Post by David Masover
Post by Dave Howell
I kept finding
tutorials that would say "or you can edit the blahblah file to work =
with
Post by David Masover
Post by Dave Howell
an existing legacy database." However, I couldn't even *get* a =
blahblah
Post by David Masover
Post by Dave Howell
file to edit from either Rails or Ramaze,
=20
Well, but which file? If it was schema.rb, I don't know that it =
would've=20
Post by David Masover
helped...
=20
Post by Dave Howell
Sinatra (or rather, the ORM that came bundled
with Sinatra)
=20
Which is that? I wasn't aware Sinatra came bundled with an ORM. I =
wasn't aware=20
Post by David Masover
that it made sense for there to be -- seems like you'd just use an ORM=20=
directly, without Sinatra knowing or caring about it.
I don't remember. Nor does it matter (to me at least), since I =
eventually selected Ramaze and Sequel.=20
Post by David Masover
Maybe, and I apologize if that's all it is. My point for getting into =
this was=20
Post by David Masover
to find out where the gap between my experience of things truly being =
easy=20
Post by David Masover
(even when starting out), and your experience of things being =
difficult or=20
Post by David Masover
impossible.
An admirable goal.=20
Post by David Masover
Unfortunately, we can't do that with all of your problems. For =
example, my=20
Post by David Masover
kneejerk reaction when I see people ask "How do I tie this to a legacy=20=
schema?" is "Don't do that, migrate to something sane." But that's =
obviously=20
Post by David Masover
wrong.
Oh, good. See below.
Post by David Masover
For what it's worth, as badly as we might need better documentation =
and=20
Post by David Masover
tutorials for working with legacy databases, I found it even more =
frustrating=20
Post by David Masover
in the world of Oracle ADF, where an existing, legacy Oracle database=20=
(complete with DBA) was assumed, and there was no easy, step-by-step =
guide on=20
Post by David Masover
getting from zero to a Hello World app.
Wheeee. {grimace}


I would suggest, however, that the best place to start is to understand =
that there's a serious problem with the very idea of "legacy" databases. =
My database is NOT a legacy database. It's a brand new installation, =
it's entirely under my control. I am beholden to nobody. To use the term =
"legacy" to describe it is extremely misleading. However, I happen to =
feel that the database itself is the most well suited component to =
ensure the integrity of the data, and the more I work with the various =
Ruby-based widgets, tools, and libraries, the more I believe this. I =
will NEVER give my Ruby code or an ORM the ability to alter my DB =
schema. I also considered and rejected MySQL as the datastore, because =
it does not meet my minimum standards for data safety.=20

You said above that your kneejerk reaction was to "migrate to something =
sane." We agree that that's not really the right response, but we might =
not agree on why. I read the Rails/ActiveRecord documentation with what =
eventually became horror. MySQL's little foibles (like silent truncation =
of over-long strings) were nothing compared to the gaping holes and =
systemic inadequacies of ActiveRecord. I assumed at first I was just =
missing an entire chunk of documentation, the one where it talked about =
how you could create foreign key relationships *in the database,* among =
other things. Instead I found pages of documentation about 'migration,' =
where the docs *bragged* about how easy it was to just swap out MySQL =
for SQLite, or vice versa, because it was supporting only the least =
common denominator of functionality from the DB engines.

I make my database engine work for a living. While it would, in theory, =
be possible to "migrate" my data from PostgreSQL to Oracle, SQLServer, =
or (I suspect) DB2, I believe it would be extremely difficult to =
replicate the current functionality with MySQL, and utterly impossible =
with SQLite. In practice, moving to a new DB store would require a lot =
of handwork, rewriting various triggers, creating new ones to replace =
the custom data types, adding new linking tables to replace the foreign =
key arrays, and so on. There is no way that it could be done by generic =
migration code.

I eventually found some other blogs wherein people had commented on =
similar experiences, which was why I wanted to reassure the original =
poster that "it wasn't just him not getting it" or some such thing. I =
knew when I started working on this project that I would find myself =
holding some assumptions that were going to trip me up, and I've tried =
to keep an open mind and learn new ways of doing stuff and of thinking =
about stuff. However, building my web apps from a data-centric, and =
DB-centric, perspective is not going to change, at least not until some =
kind of reason for doing so that's a few orders of magnitude more =
compelling than anything I've seen to date comes along.=20

Templating foundered on more or less the same problem. I first had to =
'template' web pages using Microsoft's IDC/HTX system. This would be =
what they had *before* they invented Active Server Pages. It was pretty =
awful. (For one thing, no cookies. Period.) A year or two later, I went =
looking for an alternative. I evaluated ASP, WebObjects, SilverStream, =
and Tango, and Tango blew my socks off. It did not use templating as =
such. Each 'page' was an interpreted file, the file contained subunits =
that would have markup, and then you could also embed code within the =
markup material. Not unlike Haml's partials, but it all happened within =
a single file.=20

That was in 1997. I was expecting, upon my return to DB<->web =
programming, to find things fabulously more advanced. I didn't expect to =
find them almost unrecognizable. Unfortunately, the lack of recognition =
isn't because everything's fabulously more advanced. There's been a lot =
of sideways motion.=20

The tutorial that I kept hoping to find, and that I didn't see =
*anywhere*, was the one that would start out like "Let's build a =
blogging site. Here's the tables we're going to use. Here's the SQL code =
you would run on your database to create them. Now, run this magical =
command and Railamanatra will construct models and web pages and views =
and stuff to help you get started . . . ." or maybe "Here's how to =
convert your current PHP-based blogging site to Railamanatra, without =
having to alter the existing data or database."

So, in a nutshell, there are two paradigms that are pervasive in the =
current Ruby-tool-for-web community that will tend to make people who =
don't share them incredibly miserable. The one I've mostly covered above =
is the middleware-centric perspective, and it seems fairly obvious to me =
this is because most of the current tools were created by people who =
started with Rails. Rails, as the designers clearly explain, is =
"opinionated software." I *like* that. I agree with their idea that =
there's a lot of merit in making something that does NOT try to be =
everything-agnostic, that provides suggestions, guide rails, defaults, =
and implicit assumptions. However, in this particular case, MY =
perspective is that the data is god-like, the DB engine is the emperor, =
and the middleware are its lackeys and peons, and Rails really hates =
that. Alas, all the viable alternatives I found still believe that to =
one degree or another. I picked Ramaze in the end because it felt less =
strongly about that than my other options.=20

In fact, I think that this 'opinion' is actually quite mild in some of =
the other platforms; the authors were, in fact, trying to go for a more =
generalized approach. But the *documentation* still reflects that =
original Rails point of view more strongly.=20

Just figuring out that I had to go shopping for multiple different parts =
in order to replace what Tango did for me was one unexpected stumble. =
When I did, then I realized that, for me, starting with the ORM was =
absolutely the right thing to do. I had a seriously complex schema and =
if my ORM couldn't keep up, it was pretty irrelevant what else I had. =
And Sequel has outstanding, phenomenal documentation, and appeared to =
have a notably data-centric perspective. Once I had that, then I picked =
out things that went well with it.=20

Next paradigm, see next message.
Phillip Gawlowski
2010-10-17 01:33:21 UTC
Permalink
My apologies if quoting is mangled, there's only so much I can do
about broken email clients...

On Sun, Oct 17, 2010 at 2:09 AM, Dave Howell
I would suggest, however, that the best place to start is to understand that there's a serious problem with the very idea of "legacy"
databases. My database is NOT a legacy database. It's a brand new installation, it's entirely under my control. I am beholden to
nobody. To use the term "legacy" to describe it is extremely misleading. However, I happen to feel that the database itself is the
most well suited component to ensure the integrity of the data, and the more I work with the various Ruby-based widgets, tools, and
libraries, the more I believe this. I will NEVER give my Ruby code or an ORM the ability to alter my DB schema. I also considered
and rejected MySQL as the datastore, because it does not meet my minimum standards for data safety.
Legacy system:

Wikipedia:
"A legacy system is an old technology, computer system, or application
program that continues to be used, typically because it still
functions for the users' needs, even though newer technology or more
efficient methods of performing a task are now available."

ichnet.org:
"Those systems in existence and either deployed or under development
at the start of a modernization program. All legacy systems will be
affected by modernization to a greater or lesser extent. Some systems
will become transition systems before they are retired."

bbn.com:
"A customer's existing system, often a database system."

So, yes, your database is a legacy system, as far as switching horses
(to a very different programming style and methodology for web
development) mid-race is concerned.
You said above that your kneejerk reaction was to "migrate to something sane." We agree that that's not really the right response,
but we might not agree on why. I read the Rails/ActiveRecord documentation with what eventually became horror. MySQL's little
foibles (like silent truncation of over-long strings) were nothing compared to the gaping holes and systemic inadequacies of
ActiveRecord. I assumed at first I was just missing an entire chunk of documentation, the one where it talked about how you could
create foreign key relationships *in the database,* among other things. Instead I found pages of documentation about 'migration,'
where the docs *bragged* about how easy it was to just swap out MySQL for SQLite, or vice versa, because it was supporting only
the least common denominator of functionality from the DB engines.
The least common denominator being, allegedly, the SQL standard. Which
pretty much *no existing SQL database supports in a portable fashion*.
So, what shall be done give that, a) time, b) money, c) knowledge are
in finite supply? ActiveRecord/Rails opted for portability as much as
is possible. Frankly, you can be happy that it is trivial now to
change ActiveRecord for something different and have Rails still work.
I make my database engine work for a living. While it would, in theory, be possible to "migrate" my data from PostgreSQL to Oracle,
SQLServer, or (I suspect) DB2, I believe it would be extremely difficult to replicate the current functionality with MySQL, and utterly
impossible with SQLite. In practice, moving to a new DB store would require a lot of handwork, rewriting various triggers, creating new
ones to replace the custom data types, adding new linking tables to replace the foreign key arrays, and so on. There is no way that it
could be done by generic migration code.
And given that you know how much work you face, how much *DB engine
specific* work at that, you seriously expect a tool to cover every
possible case and usage scenario? That's a rather arrogant attitude at
best.
I eventually found some other blogs wherein people had commented on similar experiences, which was why I wanted to reassure the
original poster that "it wasn't just him not getting it" or some such thing. I knew when I started working on this project that I would find
myself holding some assumptions that were going to trip me up, and I've tried to keep an open mind and learn new ways of doing stuff
and of thinking about stuff. However, building my web apps from a data-centric, and DB-centric, perspective is not going to change, at
least not until some kind of reason for doing so that's a few orders of magnitude more compelling than anything I've seen to date
comes along.
Rails is a result of work done 37signals, derived from the experiences
these people had when creating brand spanking new web applications.
That's the space Rails occupies and, for better or for worse,
dominates.

Rails never was good at being put on top of existing databases or to
fit into existing systems, since that is not the development goal for
Rails.
Templating foundered on more or less the same problem. I first had to 'template' web pages using Microsoft's IDC/HTX system. This
would be what they had *before* they invented Active Server Pages. It was pretty awful. (For one thing, no cookies. Period.) A year or
two later, I went looking for an alternative. I evaluated ASP, WebObjects, SilverStream, and Tango, and Tango blew my socks off. It
did not use templating as such. Each 'page' was an interpreted file, the file contained subunits that would have markup, and then you
could also embed code within the markup material. Not unlike Haml's partials, but it all happened within a single file.
I have the distinct feeling that you are strongly opposed to Java's
"One File, One Class" approach, too.
That was in 1997. I was expecting, upon my return to DB<->web programming, to find things fabulously more advanced. I didn't
expect to find them almost unrecognizable. Unfortunately, the lack of recognition isn't because everything's fabulously more
advanced. There's been a lot of sideways motion.
I can't comment on that, but I doubt that expecting that programming
changed since the last paradigm shift to OOP is an approach that lends
itself to safety (alas). The changes were in methodology, like the
Model-View-Controller pattern, which nicely separates area of
responsibility of code, minimizing dependencies of otherwise unrelated
code.
The tutorial that I kept hoping to find, and that I didn't see *anywhere*, was the one that would start out like "Let's build a blogging
site. Here's the tables we're going to use. Here's the SQL code you would run on your database to create them. Now, run this
magical command and Railamanatra will construct models and web pages and views and stuff to help you get started . . . ." or
maybe "Here's how to convert your current PHP-based blogging site to Railamanatra, without having to alter the existing data or
database."
That's because Rails aims to be all-encompassing. You write everything
you need in one language, instead of having to switch gears going from
Ruby to SQL to HTML. And nobody said that Rails fits your problem
space, either.

Rails is excellent if you can control everything in a project, from DB
schema, to server deployment, to the server's software. It's not a
good tool if you want to make a square peg fit a round hole, however.
So, in a nutshell, there are two paradigms that are pervasive in the current Ruby-tool-for-web community that will tend to make people
who don't share them incredibly miserable. The one I've mostly covered above is the middleware-centric perspective, and it seems
fairly obvious to me this is because most of the current tools were created by people who started with Rails. Rails, as the designers
clearly explain, is "opinionated software." I *like* that. I agree with their idea that there's a lot of merit in making something that does
NOT try to be everything-agnostic, that provides suggestions, guide rails, defaults, and implicit assumptions. However, in this
particular case, MY perspective is that the data is god-like, the DB engine is the emperor, and the middleware are its lackeys and
peons, and Rails really hates that. Alas, all the viable alternatives I found still believe that to one degree or another. I picked Ramaze
in the end because it felt less strongly about that than my other options.
Then don't use Rails. It's as easy as that.
In fact, I think that this 'opinion' is actually quite mild in some of the other platforms; the authors were, in fact, trying to go for a more
generalized approach. But the *documentation* still reflects that original Rails point of view more strongly.
That could be because the Merb and Rails teams (and code) merged
between Rails 2.0 and the current Rails 3.0 release. And as we all
know, the documentation ranks pretty low on teh "things developers do
for fun" scale (much to my own annoyance).
Just figuring out that I had to go shopping for multiple different parts in order to replace what Tango did for me was one unexpected
stumble. When I did, then I realized that, for me, starting with the ORM was absolutely the right thing to do. I had a seriously
complex schema and if my ORM couldn't keep up, it was pretty irrelevant what else I had. And Sequel has outstanding, phenomenal
documentation, and appeared to have a notably data-centric perspective. Once I had that, then I picked out things that went well with
it.
Fortunately, thanks to the middle-ware centric approach, you can
actually exchange these things with relative ease.

Well, to cut a long story short: Don't be surprised that Rails doesn't
fit your problem. Instead of venting about it, move on, and look for
something that fits, or build your own (or fork Rails / the parts of
Rails you like, and build from that). It's open source, nobody'll stop
you.
--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
Dave Howell
2010-10-17 01:17:07 UTC
Permalink
The other paradigm that I've tripped over is that I want my models to =
know how to present themselves. Tango did this to a limited extent, and =
I really liked it. I was expecting a beautiful world of =
self-constructing data when I started working with Rails. Something like =
blog.author
=3D> "Huffy Angelaton"
puts blog.author
=3D> "<span class=3D'author'>Huffy Angelaton</span>"
puts Form.new(:action=3D>"/savepost"){
blog.author
}
=3D> "<form action=3D\"/savepost"><input type=3D'text' length=3D'50' =
value=3D'Huffy Angelaton' name=3D'blog.author'></form>"

I found *nothing* that even remotely approached that. So I wrote my own.=20=


There was a pretty long discussion on the Ramaze list about this, =
because I'm well aware that this is a big-time violation of the =
Model-View-Controller idea. Unfortunately, MVC just can't handle this =
without a huge amount of extra lumps of code. Well, it can handle the =
*previous* example. But it really can't handle the following one. Or (to =
inject at least a smidge of humility), I was quite unable to find a way =
to do it.=20

This is a slightly modified example from my working code. A "Batch" is a =
particular batch of manufactured product, specifically an herbal =
medicine. I've obfuscated the UUIDs.=20
b =3D Batch['3705bf0e-4264-6654-ff6c-00065b3f562c']
=3D>#<Batch @values=3D{:wv=3D>"1:1.7", :notes=3D>nil, :active=3D>true, =
:herbpercent=3D>#<BigDecimal:101f28328,'0.0',4(12)>, :pressed=3D>nil, =
:batchcode=3D>"06082030.1", :herbweight=3D>3741, =
:lot_id=3D>"e62b56d2-a741-xxxx-xxxx-xxxxxxxxxxxx", :initvol=3D>6360, =
:created=3D>Fri Aug 04 00:00:00 -0700 2006, :finalvol=3D>8812, =
:extract_id=3D>"f2580cc8-2354-xxxx-xxxx-xxxxxxxxxxxx", =
:batch_id=3D>"3451a2a6-5fc1-xxxx-xxxx-xxxxxxxxxxxx", :id=3D>1534, =
:decocted=3D>false, =
:cultivation_id=3D>"3705ff6c-2355-xxxx-xxxx-xxxxxxxxxxxx"}>

However, a batch also contains multiple non-active ingredients, called =
components.
b.components
=3D> [
#<Component =
@values=3D{:percentage=3D>#<BigDecimal:101f220b8,'0.1E2',4(8)>,=20
:batch_id=3D>"3705ff6c-5fc1-xxxx-xxxx-xxxxxxxxxxxx",=20
=
:componentcategory_id=3D>"4ace3c04-2357-xxxx-xxxx-xxxxxxxxxxxx"}>,=20
#<Component =
@values=3D{:percentage=3D>#<BigDecimal:101f21a50,'0.5E2',4(8)>,=20
:batch_id=3D>"3705ff6c-5fc1-xxxx-xxxx-xxxxxxxxxxxx",=20
=
:componentcategory_id=3D>"4ace3f92-2357-xxxx-xxxx-xxxxxxxxxxxx"}>,=20
#<Component =
@values=3D{:percentage=3D>#<BigDecimal:101f21410,'0.4E2',4(8)>,=20
:batch_id=3D>"3705ff6c-5fc1-xxxx-xxxx-xxxxxxxxxxxx",=20
=
:componentcategory_id=3D>"4ace430c-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}>]
b.components[0].componentcategory
=3D> #<Componentcategory @values=3D{:name=3D>"Glycerine", :sequence=3D>3, =
:componentcategory_id=3D>"4ace3c04-2357-xxxx-xxxx-xxxxxxxxxxxx"}>


If I want to create a form for a user to edit the batch data, what I put =
in my code is this:

e.editform.to_form
<input name=3D'batch_id' =
value=3D'3705ff6c-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<select name=3D'cultivation_id' id=3D'Cultivation'>
<option =
value=3D'345183ca-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Other</option> =09
<option selected=3D'true' =
value=3D'3451a2a6-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Organically =
Grown</option>
<option =
value=3D'3451a68e-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Wildcrafted</option>
<option =
value=3D'3451a9b8-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>[unknown]</option>
<option =
value=3D'3451acd8-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Cultivated</option>
<option =
value=3D'3451b08e-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Grown Without =
Chemicals</option>
<option =
value=3D'77cc2f7a-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Forest Grown</option>
<option =
value=3D'c7406e90-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Wild Simulated</option>
</select>
<input name=3D'Component:8313022463:batch_id' =
value=3D'3705ff6c-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<input name=3D'Component:8313022463:componentcategory_id' =
value=3D'4ace3c04-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<select name=3D'Component:8313022463:componentcategory_id' =
id=3D'Componentcategory'>
<option =
value=3D'4acb07a0-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Olive Oil</option>
<option =
value=3D'4ace354c-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Other</option>
<option selected=3D'true' =
value=3D'4ace3c04-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Glycerine</option>
<option =
value=3D'4ace3f92-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Ethanol</option>
<option =
value=3D'4ace430c-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Water</option></select>
<input name=3D'Component:8313022463:percentage' size=3D'6' =
value=3D'10' type=3D'text'/>
<input name=3D'Component:-7531801290:batch_id' =
value=3D'3705ff6c-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<input name=3D'Component:-7531801290:componentcategory_id' =
value=3D'4ace3f92-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<select name=3D'Component:-7531801290:componentcategory_id' =
id=3D'Componentcategory'>
<option =
value=3D'4acb07a0-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Olive Oil</option>
<option =
value=3D'4ace354c-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Other</option>
<option =
value=3D'4ace3c04-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Glycerine</option>
<option selected=3D'true' =
value=3D'4ace3f92-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Ethanol</option>
<option =
value=3D'4ace430c-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Water</option></select>
<input name=3D'Component:-7531801290:percentage' size=3D'6' =
value=3D'50' type=3D'text'/>
<input name=3D'Component:-6831266729:batch_id' =
value=3D'3705ff6c-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<input name=3D'Component:-6831266729:componentcategory_id' =
value=3D'4ace430c-xxxx-xxxx-xxxx-xxxxxxxxxxxx' type=3D'hidden'/>
<select name=3D'Component:-6831266729:componentcategory_id' =
id=3D'Componentcategory'>
<option =
value=3D'4acb07a0-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Olive Oil</option>
<option =
value=3D'4ace354c-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Other</option>
<option =
value=3D'4ace3c04-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Glycerine</option>
<option =
value=3D'4ace3f92-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Ethanol</option>
<option selected=3D'true' =
value=3D'4ace430c-xxxx-xxxx-xxxx-xxxxxxxxxxxx'>Water</option></select>
<input name=3D'Component:-6831266729:percentage' size=3D'6' =
value=3D'40' type=3D'text'/>
<input name=3D'created' size=3D'12' value=3D'2006 Aug 04' =
type=3D'text'/>
<input name=3D'wv' size=3D'40' value=3D'1:1.7' type=3D'text'/>
<input name=3D'herbpercent' size=3D'6' value=3D'0' type=3D'text'/>=
<input name=3D'batchcode' size=3D'40' value=3D'55436476' =
type=3D'text'/>
<input name=3D'herbweight' size=3D'7' value=3D'3741' =
type=3D'text'/>
<input name=3D'initvol' size=3D'7' value=3D'6360' type=3D'text'/>
<input name=3D'finalvol' size=3D'7' value=3D'8812' type=3D'text'/>=
<input name=3D'decocted' type=3D'checkbox'/><textarea =
name=3D'notes' rows=3D'8' cols=3D'80'> </textarea>
<input checked=3D'' name=3D'active' type=3D'checkbox'/>
<input name=3D'pressed' size=3D'12' value=3D'' type=3D'text'/>"
A batch has more than one component, and each component can be a =
particular substance. In order to present that HTML code, my batch =
object had to know to take its own fields, like "batchcode" and turn =
them in to text input fields. The size of the field is based on how much =
space is reserved in the database itself for that data. Each Component =
of a Batch has to do the same thing. "Percentage" is a text input field =
long enough for the custom data type (a numeric(5,2) that only accepts =
numbers in the range 0.00 to 100.00). But since there are multiple =
components, and HTML forms don't have support for nesting, each form =
field has to get a unique name so that when the data comes back, it's =
possible to figure out which percentage belongs to which component.=20
Finally, each component is linked to a 'Componentcategory." In =
order to allow the user to select a different category, the form has to =
know what EVERY row in the table is, in order to create the list of =
<options>.=20

This last bit is really critical. If you just ask the object itself, it =
cannot tell you what you need to know to create the form.=20
b.components[0].componentcategory
=3D> #<Componentcategory @values=3D{:name=3D>"Glycerine", =
:sequence=3D>3, =
:componentcategory_id=3D>"4ace3c04-2357-xxxx-xxxx-xxxxxxxxxxxx"}>

To find out what other categories this component *could* be, you have to =
back up from this component category to the class, then query for all =
members of the class, then use that information to construct one form =
field, using the identity of the current active *instance* of the class =
to figure out which <option> is marked as "selected".=20

I tried to get to this point with templating, but pretty soon my =
templates were hardly more than <body><@htmlfromcontroller></body>, so =
what's the point?=20

I must admit, I'm still not too sure what paradigm IS behind the current =
flock of templating tools, except that it isn't like this, and doing it =
this way is totally rocking, so I have no incentive to change.=20
Paul McKibbin
2010-10-08 07:43:52 UTC
Permalink
[Note: parts of this message were removed to make it a legal post.]

Have you installed the mysql client software? The gem only provides bindings
to this, and without it you won't be able to connect. Since, as mentioned
elsewhere you haven't provided any of your errors, it is difficult to deduce
what is going wrong. I develop Ruby software across 3 different platforms,
including Windows, with and without Rails, and find it a rewarding
experience.

Mak
Post by Ed Reed
I'm trying to figure out what's so cool about Ruby. I need to create a
web app that runs on Windows 7 and talks to multiple ODBC data sources.
I wanted to start with just a simple app but I've been trying for three
days on three different machines with no success. I tried setting up
Ruby 1.9.2, 1.9.1, 1.8.2, and 1.8.6 and can't even begin to start
developing anything.
My steps have been
Uninstall and remove all existing Ruby installations
Install Ruby
install DevKit
run command gem install rails
run command gem install rake
run command gem install mysql
run command gem install mysql2
run command rails new mydbapp -d mysql
run command rails new mydbapp -d mysql2
I've tried numerous combinations of the above steps (obviously I didn't
perform both the mysql and mysql2 at the same time) and get errors on
install rails, install mysql, install mysql2, and rails new mydbapp.
I've searched the web for three days for answers to all the different
errors. I've found that many people seem to have the same or very
similar errors and it doesn't look like there's many successful
resolutions.
So since Ruby can't create a web database app on Windows 7 and there's
no descent place to find useful answers to problems that lead to
successful resolutions, and creating a simple app requires a ridiculous
number of steps to just set it up before you ever get to write any code,
what's so cool about it? I'm serious, I'd like an answer. I'd like to
see it work but all I've seen is errors. I don't think it can do it but
I've heard people say that it's the hot new way to do web db apps. I've
been writing web db apps for the past 12 years in a variety of languages
on numerous platforms and I've never had to deal with this. I don't see
how anyone can spend this much non-billable time before your ever get to
write any code. Can anyone answer any of these questions?
--
Posted via http://www.ruby-forum.com/.
Ed Reed
2010-10-08 19:04:25 UTC
Permalink
Post by Paul McKibbin
Have you installed the mysql client software? The gem only provides bindings
to this, and without it you won't be able to connect. Since, as mentioned
elsewhere you haven't provided any of your errors, it is difficult to deduce
what is going wrong. I develop Ruby software across 3 different platforms,
including Windows, with and without Rails, and find it a rewarding
experience.
Mak
I did include the errors in an earlier reply and as I also mentioned
earlier I was able to make a small amount of forward progress which
would indicate that I do have the necessary client software installed.
Unfortunately, since the dbd-mysql "snap-in" is apparently a dead
project it seems pointless to continue down that path and I need to try
a different direction. Not that this was the only issue in the
discussion. The main point was a much more "thirty thousand foot view"
of Ruby DB/CGI app development in general.
--
Posted via http://www.ruby-forum.com/.
namekuseijin
2010-10-09 16:53:09 UTC
Permalink
ah, nothing like a good warm cup of RTFM up in the morning, huh?
b***@gmail.com
2010-10-10 16:36:47 UTC
Permalink
Xavier Shay:
Rails 3, Ruby 1.9.2, Windows 2008, and SQL Server 2008 Tutorial:

http://rhnh.net/2010/10/10/rails-3-ruby-1-9-2-windows-2008-and-sql-server-2008-tutorial
Eduardo Blumenfeld
2010-10-13 03:03:05 UTC
Permalink
Did you try IronRuby?

It is very easy to work with odbc, appart from interoperating with .net
directly.

Regards,

Eduardo
--
Posted via http://www.ruby-forum.com/.
Loading...