1. Can I call my java classes or would I be looking at a complete
rewrite in ruby?
2. How effective is ruby in terms of seperation of concerns regarding
design from content?
3. I have a number of hibernate maps accessing various postgresql
tables. Can I reverse engineer those tables into rails (maps?) ?
4. In cocoons mvc (flowscript) it is possible to instantiate and call
class methods from within the document at the same time as directing
flow. Is this possible in ruby/rails?
--
Regards
Andrew
I come from a JBoss/J2EE/Java background and I have been working on my
first RoR project for the last several months... all-in-all it is a
pleasure! If you are new to RoR, it will take a bit to get used to the
syntax but once you do, it is amazing how quickly one can get things
done and do it in a structured, test-oriented way.
RoR has ActiveRecord that is analagous to Hibernate or EJB3. It
supports many of the features and maps relationships nicely. Some of
the features I don't see (someone please correct me if I am wrong)
are:
- lazy-loading/eager-loading ability
- object caching (like JBoss Cache)
In your situation, I wonder, rather than do a total immediate rewrite,
seeing you are using JBoss, why not keep JBoss as your object/db
broker with Hibernate and extend it out using Web Services and call
that from a RoR front-end? That way, you could migrate slowly rather
than wholesale.
Scott
On Feb 27, 7:51 am, "Luke Ivers" <technod...@gmail.com> wrote:
> It can be used as such, although I'm not sure that I would call that it's
> default application.
> And you could do exactly what you're asking using AJAX and Rails's links to
> it... it is one of the major aspects of Rails that promotes it above and
> beyond most of the other frameworks available... you could even have it load
> up the artistDetails2.xml file into the page it's already on, instead of
> directing them to yet another page.
>
> On 2/26/07, Andrew Madu <andrewm...@gmail.com> wrote:
>
>
>
> > Hi Luke,
> > many thanks for the information you have provided thus far.
>
> > In regards to my question 4, an example might suffice: (myArtistDetails.js
> > )
>
> > importClass(Packages.test.Artist); Flows equivalent of package test;
> > import Artist;
>
> > function artistDetails() {
>
> > try {
> > artistID = cocoon.parameters.artistID;//either use defined or
> > specified from dB
> > artist = Artist.getArtist(artistID); //Artist id passed into class
> > method
>
> > artist_name = artist.getArtistName();//artist name is obtained
> > from the Artist class
> > artist_info = artist.getArtistInfo();// as above
>
> > }catch(e) {
> > }
>
> > cocoon.sendPageAndWait("artistDetails2.xml",{"artistID":artistID,"artist_na me":artist_name,"artist_info":artist_info});
> > //MVC: flow is directed to rtistDetails2.xml with associated values
> > }
>
> > In the above flow (MVC) document a java class is imported, its method
> > interrogated and corresponding values passed onto the next document in line.
> > How would this be handled in Ruby/Rails, such that an action on a web page
> > causes artistDetaills() to be called and then directed on to
> > artistDetails2.xml?
>
> > Am I correct in thinking that rails is a mapping technology much like
> > hibernate?
>
> > --
> > Regards
>
> > Andrew
>
> > On 26/02/07, Luke Ivers <technod...@gmail.com> wrote:
>
> > > Ok, to start with, I don't really understand what #4 means, but I think
> > > I can address the other well enough:
> > > #1: If the application is fairly complex, you'd probably be looking at a
> > > full re-write... however, there is a project called JRuby that is attempting
> > > to change that statement. It allows you to run Ruby scripts on the JVM, and
> > > it allows you to reach out to existing Java code and call things in it...
> > > however, it's support for Rails isn't 100% atm... it can do basic stuff,
> > > moving on up into intermediate, but extremely complex code is better left
> > > outside of JRuby atm.
> > > #2: Excellent. It is on par with the best of any other framework I have
> > > ever known in this regard.
> > > #3: Using Rails, you generally don't have to do much of anything to
> > > support already existing tables... Rails just reads in the schema info from
> > > the DB, and auto-generates all kinds of nifty things for you... the minor
> > > exception to this is that if you aren't using the default names that Rails
> > > likes in your DB (it wants the primary key auto-increment id field to be
> > > named id, etc) you have to specify them in your file like so:
> > > class User < ActiveRecord::Base
> > > set_primary_key "userid"
> > > end
>
> > > Many people find On LAMP's Rolling with Ruby on Rails tutorial a great
> > > place to find out what Rails can offer: the revisited tutorial is
> > > particularly good in this respect:
> > >http://www.onlamp.com/pub/a/onlamp/2006/12/14/revisiting-ruby-on-rail...
I come from a JBoss/J2EE/Java background and I have been working on my
first RoR project for the last several months... all-in-all it is a
pleasure! If you are new to RoR, it will take a bit to get used to the
syntax but once you do, it is amazing how quickly one can get things
done and do it in a structured, test-oriented way.
RoR has ActiveRecord that is analagous to Hibernate or EJB3. It
supports many of the features and maps relationships nicely. Some of
the features I don't see (someone please correct me if I am wrong)
are:
- lazy-loading/eager-loading ability
- object caching (like JBoss Cache)
In your situation, I wonder, rather than do a total immediate rewrite,
seeing you are using JBoss, why not keep JBoss as your object/db
broker with Hibernate and extend it out using Web Services and call
that from a RoR front-end? That way, you could migrate slowly rather
than wholesale.
Hi Andrew,
I come from a JBoss/J2EE/Java background and I have been working on my
first RoR project for the last several months... all-in-all it is a
pleasure! If you are new to RoR, it will take a bit to get used to the
syntax but once you do, it is amazing how quickly one can get things
done and do it in a structured, test-oriented way.
RoR has ActiveRecord that is analagous to Hibernate or EJB3. It
supports many of the features and maps relationships nicely. Some of
the features I don't see (someone please correct me if I am wrong)
are:
- lazy-loading/eager-loading ability
- object caching (like JBoss Cache)
OK! I am using hibernate with ehcache handling lazy object caching. Can anyone else confirm whether ActiveRecord supports lazy-loading/object caching?
1. Database.
I am using postgreSQL 8.1 . Would rails be able to reverse engineer the required ActiveRecord maps from the dB schema? From what I understand of rails convention table names need to be pluralized. How would the reverse engineering process handle the fact that none of my table names are pluralized?!
2. Form validation
I am using Ajax to handle all form validation in cocoon. In cocoon form dev/validation would be handled by:
a. Specifying that you wish Ajax to handle validation as so:
<ft:form-template action=" login.kont" name="Form1" method="POST" ajax="true">
b. Defining your form widgets in a seperate document as so:
<ft:widget id="password">
<fi:styling size="30" type="password" class="keyinbox" style="background-color:#C9C4BD;" />
</ft:widget>
c. Defining your validation, against your widgest, in another document as so:
<fd:field id="password" required="true">
<fd:datatype base="string"/>
<fd:validation>
<fd:length min="5" max="20"/>
</fd:validation>
</fd:field>
3. Paypal API.
I have recently come across a ruby/rails Paypal (directpayment api) so this area is covered.
4. Image handling.
All artist images are stored in postgresql and read into the webapp as svg via Base64. Cocoon then allows for an svgTOpng or svgTOjpeg conversion before the image is rendered to the page. As an example I have various img calls defined as such:
<image src="artistImage/${artistID}/228/202/${stock_code}.svg" alt="${artist_name} - ${track_title}"/>
So in effect the img tag is making a call to the database which in turn return the appropriate binary information, holds it in svg format before converting it to either PNG or JPEG. How would ruby/rails handle this?
5. Email/Zip
I have a process where by the artist track files (mp3) a user may have ordered are pulled out from their order/order_items object, read in the file system directory and then zipped up. This zip is then emailed to the user. How would ruby/rails handle this process?
--
Regards
Andrew
My personal experience with Cocoon / JBoss / etc tells me to NEVER just port code from these frameworks to Rails.
2) Look into RJS. This acts much in the same way as what Cocoon seems to do, defining partials of HTML code that get pushed to the client.
4) Check out the fleximage plugin: http://agilewebdevelopment.com/plugins/fleximage Should take care of all your needs with this.
class Order < ActiveRecord::Base
has_many :items
end
You'll want the Agile Web Development with Rails book from the
Pragmatic Programmers. IT covers all the technologies plus a lot more
and also contains a very useful reference to the rails framework.
--max
> One further question if I may, in terms of persisting an objet retrieved
> from a dB table? Currently I retrieve the hibernate dB object and store it
> in a session object. I take it that ruby/rails/activerecord would function
> in much the same way?
>
Yes, you can do that. However it's of course better pracice not to
store any application state (even temporary) in the session.
> I just came across some activerecord code:
>
> class Order < ActiveRecord::Base
> has_many :items
> end
>
> That's it?! One line of code to setup a one-to-many relationship between an
> order and order items table?!!! ;-)
Yes! And if you like that one, wait until you find out about the
really cool stuff ;)
--max
You'll want the Agile Web Development with Rails book from the
Pragmatic Programmers. IT covers all the technologies plus a lot more
and also contains a very useful reference to the rails framework.
class Item < ActiveRecord::Basebelongs_to :orderend
I also like the two-line ajax autocompletion:
in the view:
<%= autto_complete_field :user, :name %>
in the controller:
auto_complete_for :user, :name
Done.
Some of the plugins do amazing things too, such as acts_as_versioned.
One line of code to get a complete versioned history of every update
to a model, complete with rollback to a previous version. The code?
class WikiPage << ActiveRecord::Base
acts_as_versioned
end
and then
wiki_page.revert_to(wiki_page.version-1) # get previous version
;)
--max
there is no equivalent to the Cocoon flowscript (with the
continuations and all).. not that its a blocker, just be aware that
coding forms is different :)
-pete
--
(peter.royal|osi)@pobox.com - http://fotap.org/~osi
On Feb 27, 9:18 pm, "Luke Ivers" <technod...@gmail.com> wrote:
> I love that everyone moving from a different framework (with the possible
> exception of things like Django) has these moments: the "oh my god it's so
> easy" ones.
Yeah. I was excited when EJB3 came out after years of EJB2/xDoclet.
Now, I won't even consider working on anything except RoR. Unless, I
get paid enough, of course. ;-)
That is very cool. I have a similar thing in the app I am working on
now, I am going to give that a whirl. Thanks!
Assignable meaning not auto_increment and you take care of the value yourself?
ActiveRecord doesn't really like that. It basically requires that it take care of handling the primary key.
I'm not sure if there's a plugin to work around this, but you'll probably have to jump into AR itself if you start getting crazy with the keys.
This is a very standard, basic model setup. It will work just fine in
Rails. Generate models for order and order item, then add to order.rb:
has_many :order_items
add to order_item.rb
belongs_to :order
and Rails will work as you describe. The curious thing is why you
don't trust Hibernate to perform id management for you? Are you doing
something unusual?