I am planning to move my app from Standard Rails UI with form_for to
using widgets from jQuery/ExtJS...
Most of these take json format.
I can easily get JSON Format from Rails model, but updates will also
send JSON format.
This essentially means the default Rails UI and its helper methods will
become useless. It also means that when posting from Model I can try to
be consistent, as I am using for example nested attributes on Model
side, however most of the View Side will not be able to use anything
from form_for and the partials looping for collections.
Is that the Same Experience others have had?
Want to hear from Someone out there....
Any tips. Don't want to replace by Rails Plugins. I am good at
JavaScript along with Ruby.
We went down the ExtJS path and it was a painful one. The widgets can provide a nice user experience but it comes with a high price on the development side. When you step off the golden path with Rails you lose a lot of the magic. We are in the process of removing ExtJS from our application because there was just too much pain.
We went down the ExtJS path and it was a painful one. The widgets can
provide a nice user experience but it comes with a high price on the
development side. When you step off the golden path with Rails you lose
a
lot of the magic. We are in the process of removing ExtJS from our
application because there was just too much pain.
Thanks Anthony for feedback.
However, not using UI widgets at all would be
loosing a lot of great user interface goodness...
Overall you can make Rails Standard UI better
but when you need ExtJS grids you need them.
Web Service style json
output... and input in JSON would have to be created
so that params get populated in similar way....and models
remain same.
It's harder I agree. Lots of output json JavaScript massage...
But in the long run your website will operate better.
I know jQuery has serialize form style. However,
we also need some standard JavaScript libray functions
to lessen this pain......
I think it depends on the application / website you want to build.
For me and the applications I built with it, Ext JS and Rails have
been the perfect combination.
Not sure what you mean with losing a lot of the magic of Rails.
I'm not a fan of erb/haml, partials and rjs.
The true magic for me in Rails lies in the model and controller level,
and that part you obviously don't lose when using Ext JS.
I love the clean separation of controllers and views you get when
working with Ext JS.
You basically build an API for your app right away. So in case your
app needs an API for third party stuff later, you already have that,
you just need to add the API authorization stuff.
"I can easily get JSON Format from Rails model, but updates will also
send JSON format. "
What do you mean with "but updates will also send JSON format."?
This isn't a problem at all. Ext JS sends the updates in a JSON format
which the Rails controller understands automatically.
So if your Ext JS Store sends { product: { name: 'something' } }, you
just need to do @product = Product.new(params[:product]) on the
controller side.
No decoding or anything like that.
P.S. If you're a fan of helpers, then you won't miss much in Ext JS.
Ext JS allows you even better encapsulating of UI logic. You can write
you custom classes/widgets, plugins, renderers, formats.
I think it depends on the application / website you want to build.
For me and the applications I built with it, Ext JS and Rails have
been the perfect combination.
Not sure what you mean with losing a lot of the magic of Rails.
I'm not a fan of erb/haml, partials and rjs.
The true magic for me in Rails lies in the model and controller level,
and that part you obviously don't lose when using Ext JS.
"losing a lot of the magic of Rails" implies unless we make sure JSON
updates and gets follow the rails convention then a lot of magic that
comes with controller/model is lost, since your UI code from ActionView
Helper is completely lost.
For example, say with model nested attributes accepted in rails. Here
the View Helper product input tags that when submitted the Controller
can directly process it. Now when we use any JS library jQuery or YUI or
ExtJS, we have to make sure that it follows the same convention in which
Rails expects the format. If we follow the format, then it should be a
lot less of a hassle since Rails magic is embedded from Rails View side
in getting data to controller in the particular format.
The Data in JSON and the format in which Controller expects the Hash to
come in.
Hence, steps are:
1. Make a standard rails app with specific rails ActionView helpers
like form_for
2. Note the Input format that controller needs for params.
3. Try not changing the format so you can use the same Model/controller.
This comes in JSON format from the JavaScript library you are using.
4. Remove the ActionView helpers from Rails and replace with the
JavaScript library.
Do you agree? I think that is what I am saying here and you are also:-)