Mark Horrocks wrote:
Bb Serviss wrote:
Many thanks to everyone who replied, this is a great forum. Delphi has
been kind to me with the (visual component library) client data set
which allows me to make a single query, then scope the remaining records
in any way I see fit and loop through them, breaking out of the loop
anytime I see fit.
Delphi has been unkind to you, then. That's a bad way to interact with
a database. In general, it is much better practice to have the DB
narrow down the data as much as possible and loop through as few records
as possible on the app side.
I can also use summary functions on the cds to return
sum and count, etc, all without any further queries.
Your database can already do this. Please learn about SQL aggregate
functions, which are the correct way to achieve this. (Rails abstracts
these in the Calculations module.)
Anyway, enough of
Delphi, the requirement to use Windows servers has finally killed Delphi
Nobody's made an open-source Kylix clone?
The basic tasks I need to learn in Ruby are
1. create an array of hashes (records). I guess this is the result of a
query. (cars = Car.all) but I also need to create them by hand
2. Loop through the array, reading each record (I figure I can test each
record rather than limit the records in the apparent dataset ala
SetRange and perform some processing.
3. Breaking out of the loop anytime a condition has been met (e.g. the
game has been booked).
No. You're going about this entirely the wrong way. You seem to be
trying to copy your Delphi application line by line. If that is even
possible, it will lead to unidiomatic Rails.
What I would recommend instead is this: learn the Rails framework's
basics (from the Rails Guides or elsewhere), then reimplement the
*functionality* of the Delphi app in Rails, not its *architecture*.
Remember to do all development test-first (I recommend RSpec and
Cucumber). In fact, if you can write Cucumber stories for your Delphi
app, you'll know when you've copied the functionality properly.
I am sure there are plenty of material available to learn from. What I
really get from forums like this are hints as the the *best* way to go
Hint: don't try to write Delphi in Rails. If you really want to do
that, I'm sure you can find a Pascal Web framework...
So far I am really enjoying RoR and have been playing with
it for over a year now and have made a couple of applications similar to
the Depot sample in the excellent book Agile Web Programming.
Then you should already have a basic idea of how a Rails app works, and
you should try to use that structure instead of what you're used to from
Bonus tip: your lack of familiarity with the Array class suggests that
you need to get more familiar with basic Ruby, apart from Rails.
Good luck! Please don't hesitate to ask if you have further questions.