Topic: Re: Black Box Abstraction across websites

The MVC philosophy of rails and the url rewriting seem to be the perfect setup for creating mashups.  My question is what are the means of doing this in rails?  Here are two specific problems that cover a general type of information transfer:

-----------------------------------------
Problem 1: (Getting an HTML response)

Application 1: a wiki like revision/colaboration system of howto's.
Application 2: An issue tracking system for pc support.

Search the howto database based on the keywords of a new issue submitted to the issue tracker and suggest to the technicians what howto they should consult to solve the problem.

-----------------------------------------

Problem two: (Getting Data)

Application 1: An issue tracking system for pc support (all personnel have a tallied effort total)
Application 2: A project management tool for development of new applications (all personnel record their effort in time)

Create a third application that generates reports based on personnel and how much time they are spending in each area using graphs.

-----------------------------------------

Feel free to brag about other related features in rails, or compare and contrast other solutions to these types of problems.  References to other sources of information on the subject would be appreciated.

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Re: Black Box Abstraction across websites

For the first problem:

Rails is increasingly being understood as something that is not revolutionary.  Rather, it's a simple and pure way of combining the best of current knowledge about how to build an application.
The framework for any howto or issue tracking system in Rails would be quite simple and painless to implement (compared to most other frameworks).  The real trick is the algorithm used to lookup the correct howto based on natural language processing within the request.  For this type of problem Rails offers no advantage and you would need to start from scratch rolling your own data parser and lookup engine.
The upside is you have your choice of doing it in either Ruby or C.

for the second problem:

Rails in it's current incarnation is the mature version of what was originally just a project management tool.  Rails is, by it's very nature, perfect for managing tasks and users and the relationships involved.  It would be a small feat to add time tracking for users to this structure.

Re: Re: Black Box Abstraction across websites

I'm sorry, I guess I wasn't very clear.  I've no problem writing the applications by themselves.  What I'd like to know is if it's possible to combine websites in a black box like way.  How could I call a controller's action that would return a rendered template or perhaps primative data (intiger, array, block, function) from a different website/application?

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Re: Black Box Abstraction across websites

Ahhh, sorry bro - I totally misunderstood.

Well, there's two totally different ways to do it:

1) make one of them into an engine.  Rails has the capability to wrap an entire application up as an 'engine' and make it run as a subset of another application. So 'http://myapp/' is your application but 'http://myapp/crazymap' is some mapping engine that could run on it's own.

2) Use an API.  In the past there have been some really complicated ways of getting data from one server to another.  There are some really complicated solutions like SOAP and others (usually using XML as the intermediate language) but Rails is about to get something much, much cooler.  DHH recently gave a talk in which he announced the creation of something he's calling ActiveResource.  Basically it allows one application to create instances of another apps models and work with them as if they were native - and it all happens on XML over HTTP.
DHH's presentation

Re: Re: Black Box Abstraction across websites

Thank you. That's exactly what I wanted to know.  I didn't want to start writing a proprietary xml exchange system when there was already something out there.  I need to watch that presentation, and it might answer my questions, but in case it doesn't I'll ask:  When will this be released?  Is there any way to contribute, or is dhh working alone on this one?

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Re: Black Box Abstraction across websites

circuitshaman wrote:

Thank you. That's exactly what I wanted to know.  I didn't want to start writing a proprietary xml exchange system when there was already something out there.  I need to watch that presentation, and it might answer my questions, but in case it doesn't I'll ask:  When will this be released?  Is there any way to contribute, or is dhh working alone on this one?

IIRC he said ActiveRecord won't be done for a while, it might not be in the core until 2.0. I'm sure you could submit patches on the trac if you want to contribute though.

Railscasts - Free Ruby on Rails Screencasts

Re: Re: Black Box Abstraction across websites

Unless your interest is strictly theoretical I wouldn't wait for the release of ActiveResource.  Many Rails apps have had success with a simple API.

What you would have is a model or set of models - I'll use @users as an example - that you expose to the internet using XML.  It's as simple as using the following code in your controller:
[code lang=ruby]
def index
  @users = User.find(:all)
  respond_to do |type|
    type.html
    type.xml { render :xml => @users.to_xml }
  end
end
[/code]

If that code were in a Rails site's controller then a user in a normal browser would see the normal html page full of users in whatever layout the site had.  But if an xml file was requested the only thing returned would be an xml-formatted list of users.

You could then have a second app open the http://firstapp/users/index.xml and parse the file it gets into a bunch of users.  It's not done automatically for you so there will be at least a little programming for you to do on your own, but it's much easier than most frameworks and it's definitely faster than waiting for ActiveResource.

Hope this helps!

Re: Re: Black Box Abstraction across websites

Thanks for both of your comments.  That code snippet is helpful as well.  It seems straight forward enough.  I'll see what I can do to help on the trac.

How would I call said "http resource" in a controller so that I could parse the data out of it?

Feel free to ignore this paragraph:

  My best resource for learning the powerful functions and philosphies in rails has been sifting through the api with a combination of cue's from this forum and luck with the find function in my browser.  The sad thing about that statement is I have the "Agile Web development with rails" book, but as the pirate on the sympsons once put it, "Dar, she blows."  It made me feel like I was reading the transcript of a 40 year old man who'd just eaten a bowl of dry coffee, who'd discovered the hack saw and wanted to tell me how to use it by shouting "look at all the crazy stuff I can cut through!" and then dashing about cutting through things.  The most helpful thing, by far, are the DHH blocks.  I wish there was  way I could give meaningful critiques and help the authors write the next book, but right now I'm stuck venting BS on a forum:)

Last edited by circuitshaman (2006-08-05 09:37:21)

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Re: Black Box Abstraction across websites

circuitshaman wrote:

I have the "Agile Web development with rails" book, but as the pirate on the sympsons once put it, "Dar, she blows."

I don't think I've heard anyone put it quite like that :-)

Yeah, the book helped me to do a few particular things but most of my knowledge has come from sifting through the soure (ActionView Helpers in particular).  Hopefully we can provide enough help to each other here on the forum that in the future Googling actually gets answers.

Or you could follow the tradition of the early Rails programmers and just publish your own book :-)

Re: Re: Black Box Abstraction across websites

Thanks for the tip.  This forum has been a huge help.  I'd love to do some natural language processing on it and turn it into a wiki.  I was hoping to find the time to write a BB in rails and add that functionality in along with a way to suggest to book authors what the big problems are and even how their books are being used and what they should focus on or clarify in the next edition.  Perhaps give them a rating based on how many times people say that it blows.  But I'm not willing to put the time in to adding that funcationality to a php based bb.  PHP makes me want to naw my legs off after 30 minutes of writing fresh code, let alone trying to use someone elses.  I saw that thread about writing a forum in rails, but it seems to have died out.  It's hard to be motivated to write something that's already been done 50 times.  But anway, thanks for your help, I'll be reading up on the ActionView helpers.

Last edited by circuitshaman (2006-08-05 10:42:18)

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)