У меня есть форма, которую отправляет пользователь.Форма для пользователя.В моем файле rout.rb есть следующее:
resources :users, :except => [:new]
root :to => 'pages#home'
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
В файле users_controller.rb:
def create
@title = "Home"
@user = User.new(params[:user])
respond_to do |format|
if @user.save
format.html { redirect_to user_path(@user), :flash => {:success => "Your friend's details have been saved.The surprise has begin"} }
format.js
else
format.html { render :template => 'pages/home'}
format.js
end
end
end
Эта форма отправляется с обычным запросом POST, а не с помощью Ajax.
Я хочу знать, почему шаблон Обновления запрашивается после успешной отправки формы вместо Показа.
Вывод из маршрутов рейка следующий:
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
root /(.:format) {:controller=>"pages", :action=>"home"}
contact /contact(.:format) {:controller=>"pages", :action=>"contact"}
about /about(.:format) {:controller=>"pages", :action=>"about"}
help /help(.:format) {:controller=>"pages", :action=>"help"}
Заранее спасибо.