So, the main question is: What would be the best way to develop a RIA with Rails and ExtJS while still getting the most of out of Rails (RESTful design, testing, excellent maintabilty) and also from ExtJS (desktop-like experience, no page reloads)?
My opinion is: Unless ExtJs gets completely abstracted in Ruby/Rails (something that Ext GWT did for Java/GWT), if you really want to benefit from ExtJs for Rich Internet Applications, you will have to shift your mindset and don't treat Rails as the central toolbox/ "cockpit" for the application. You will have to get your hands dirty and write JavaScript in separate JS and HTML files. Rails would then serve the necessary data via JSON. I don't see also any use for Rails views here.
Best regards
Peter De Berdt
Exactly, if you want to develop an RIA with something like ExtJS or SproutCore, you create the frontend in ExtJS/Sproutcore code and use Rails purely as a way of serving and handling data. That doesn't mean Rails is less important to your application, it only means you won't be doing your views in Rails for the most part.
Exactly, if you want to develop an RIA with something like ExtJS or SproutCore, you create the frontend in ExtJS/Sproutcore code and use Rails purely as a way of serving and handling data. That doesn't mean Rails is less important to your application, it only means you won't be doing your views in Rails for the most part.
Yeah, this is exactly where the main question is: Should you use ERB and Rails/Ruby to help you assemble your ExtJS front-end code?
That is where I'm still confused. I don't know yet if I should treat Rails as a black-box data-only back-end, or if I should generate my ExtJS code from Rails. I can see advantages of doing it from Rails, as you can abstract some concepts as needed and make things simpler. Also, deep integration is easy, if needed (such as writing data directly into scripts/html etc).
However, I've seen in many places and even in the book "Practical Rails Projects" that ExtJS is used for its widgets and layout capabilities. Ok, that's fair, but the authors don't really develop a RIA. There is still complete page reloads which implies in complete ExtJS reload too. That's definetly not RIA but an enhanced Ajax experience only.
What I want to do is serve a RIA, Flex-like. However, I want to do it the best way. I can see many security problems if you end up exposing too much of your application on the client side, too.
I think I will go developing a PagesController, make an index action, configure the application layout to include the ExtJS JS files, and make the whole RIA in this index.rhtml template. This way, I can compartimentize other views as rhtml or rjs templates, if needed - even though I can't really think of a good reason to pre-process them other than hiding it from the public webserver and controlling access to it, which can be a good thing, of course. Then, I can also write static JS files as needed and put them in the public dir.
This way I would have the best of both worlds, and could use ruby to abstract some ExtJS concepts if I ever feel the need to.
What do you think?
I would use Rails to assemble the pages, however... I would seriously advise you to dive into page caching and have apache (or nginx) serve up the cached pages. After all, an RIA starts off with defining a grid with no real dynamic data in it, it would be a terrible waste of CPU cycles to generate those pages over and over again.
The main reason why it's still interesting to use Rails for the initial page generation is its url generation. If you write everything in static JS files and you or Rails (like it did at a certain moment with rest_action;edit to rest_action/edit) decides to change the url generation scheme, you'll have to plow through all of the static code, not very pleasant. ExtJS in its latest version supports all of the REST verbs btw, but iirc it doesn't follow the same convention as Rails, you'll have to look into it.
A second reason to still use Rails for page generation, is the authenticity token. I'm going to save you the trouble of finding out how to do pass in the token on every AJAX request. Add the following code on top of your main layout (the one that is used on every single page):
And one word of warning about ExtJS: read up on the license, I don't know what it is right now, because it has been changed a number of times. Jack Slocum is trying to find a way to make his hard work pay off, but it's been hard on him (and a lot of dismay amongst the extjs users for it, although justified also unfair towards Jack).
I would be more tempted to use SproutCore for an RIA btw, it's syntax is a lot more rubyesque. It has less prechewed components to make use of, but it's a lot, and I mean a lot cleaner and browser friendly (in terms of memory use and event handling for example).And although ExtJS has possibilities to work with Google Gears, SproutCore is the first RIA framework that makes offline web apps a breeze. And it has a nice future, with Apple being one of the big players putting its shoulders under the project.
Yes.
Rendering Ext JS with traditional Rails views using a simple gem
extjs-mvc
http://www.extjs.com/blog/2009/09/30/ext-js-on-rails-a-comprehensivetutorial/
--
Posted via http://www.ruby-forum.com/.