How can I return a json packet?

I used extjs and ror,this is the part of my ror code:

def create

@enterprise = Enterprise.new(@params[:enterprise])

p @enterprise

if @enterprise.save
flash[:note] = ‘Enterprise unit was successfully created.’
p “michael”
redirect_to(:action=>index)

else
  p "error"
  render_action 'new'
end
p 'end'

end

but each time my explore can’t direct to another page.I ask the
extjs,here is the ansower:

Form’s submit method performs an Asynchronous submit via an Ajax
request. It looks for a success attribute in the JSON packet which is
returned by the server-side. Change the response to {success: true}
and then in your success handler redirect the page via JS.

so how can I return a json packet from ror

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs