Mark H. 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
- 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Â
- 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.
- 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.Â
Sent from my iPhone