# How can I use ext with rails?

**URL:** <https://www.ruby-forum.com/t/how-can-i-use-ext-with-rails/112998>\
**Category:** Rails\
**Created:** [August 25, 2007, 5:12pm UTC](https://www.ruby-forum.com/t/how-can-i-use-ext-with-rails/112998 "2007-08-25T17:12:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hashman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/cdc98d/32.png) [@hashman](https://www.ruby-forum.com/u/hashman)\
**Post date:** [August 25, 2007, 5:12pm UTC](https://www.ruby-forum.com/t/how-can-i-use-ext-with-rails/112998/1 "2007-08-25T17:12:33Z")

</div>

Sorry to my poor english.  
I’m just beginning to use Extjs with Rails.There is problem with the  
form submit.  
Here is the rhtml code:

Here is the js coe:

- ================ Simple form =======================  
\*/

var simple = new Ext.form.Form({  
labelWidth: 75, // label settings here cascade unless overridden  
action:’/entry/create/’  
});

simple.add(  
new Ext.form.TextField({  
fieldLabel: ‘name\_native’,  
name: ‘enterprise[name\_native]’,  
width:175  
}),

new Ext.form.TextField({  
fieldLabel: ‘name\_eng’,  
name: ‘enterprise[name\_eng]’,  
width:175  
}),

new Ext.form.TextField({  
fieldLabel: ‘address’,  
name: ‘enterprise[address]’,  
width:175  
}),

new Ext.form.TextField({  
fieldLabel: ‘tel’,  
name: ‘enterprise[phone]’,  
width:175  
}),

new Ext.form.TextField({  
fieldLabel: ‘http’,  
name: ‘enterprise[http]’,  
width:175  
}),

new Ext.form.TextField({  
fieldLabel: ‘email’,  
name: ‘enterprise[email]’,  
width:175  
})  
);

simple.addButton(‘Save’,function(){  
simple.submit({ success:function(){alert(‘success’);},  
failure:function(){alert(“failure”);

} });});  
simple.addButton(‘Cancel’);

simple.render(‘form-ct’);

}}  
}();  
Ext.EventManager.onDocumentReady(index.init,index)

And here is the rails code:  
class EntryController \< ApplicationController  
def index  
end

def new  
@enterprise=Enterprise.new  
end

def create  
@enterprise=Enterprise.new(@params[:enterprise])  
if @enterprise.save  
redirect\_to(:action=\>‘index’)  
else  
render\_action ‘new’  
end  
end  
end

but each time,the code always alert “failure” ,and the data is wroten  
to the database successfully.I don’t know what happend.The correct  
resualt is the page will redirect to  
another page.
