# Moving to Widgets from Standard Rails UI

**URL:** <https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632>\
**Category:** Rails\
**Created:** [April 10, 2010, 2:54am UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632 "2010-04-10T02:54:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [April 10, 2010, 2:54am UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632/1 "2010-04-10T02:54:23Z")

</div>

Hi:

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.

Thanks much.

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [April 11, 2010, 5:16am UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632/2 "2010-04-11T05:16:04Z")

</div>

Smart RoR,

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.

Anthony C.

> **[Commonthread](https://commonthread.com)**
>
> Instantly connect and build rapport with anyone you meet, in person or online.

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [April 11, 2010, 2:24pm UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632/3 "2010-04-11T14:24:14Z")

</div>

Anthony C. wrote:

> Smart RoR,
> 
> 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.
> 
> Anthony C.  
> [http://commonthread.com](http://commonthread.com)

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…

Any more feedbacks and solutions here…

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [April 11, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632/4 "2010-04-11T18:03:59Z")

</div>

Sorry, somehow didn’t see the original message.

Smart RoR,

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.

Check that example:

> **[RESTful store example with Rails](http://www.extjswithrails.com/2009/06/restful-store-example-with-rails_04.html)**
>
> Yesterday Ext released the second release candidate of Ext JS 3.0. It included a new restful configuration option for the Ext.data.Store a...

Steffen

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.

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [April 11, 2010, 6:04pm UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632/5 "2010-04-11T18:04:34Z")

</div>

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.

Just my 2 cents.

Steffen

> **[Ext JS with Rails](http://www.extjswithrails.com)**
>
> Tips and Code for using Ext JS with Ruby on Rails.

[http://spreadnotes.me](http://spreadnotes.me)

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [April 11, 2010, 6:30pm UTC](https://www.ruby-forum.com/t/moving-to-widgets-from-standard-rails-ui/186632/6 "2010-04-11T18:30:09Z")

</div>

Steffen wrote:

> 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.
> 
> Just my 2 cents.
> 
> Steffen  
> [http://www.extjswithrails.com](http://www.extjswithrails.com)  
> [http://spreadnotes.me](http://spreadnotes.me)

Thanks Stephen.

“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:-)

Thanks.
