呈现页面并显示错误消息

时间:2018-08-29 11:48:51

标签: ruby-on-rails-4

我正在使用Rails 4.2.5和Ruby 2.3。

我正在尝试呈现如下页面:

http://localhost:3000/abcd/users/microsoft/questions/new?section_id=abc
Here microsoft is a slug
& abc is a particular section where the page should be.

在routes.rb中:

scope '/abcd' do
  resources :users, only: [:index, :show] do
    resources :questions, only: [:new, :create, :show], controller: :user_questions
  end
end

因此,我想以一种形式显示rails错误消息。

在控制器中:

respond_to do |format|
   render action: 'new', id: some_user_id, section_id: section_id and return
   format.json { render json: @error_messages, status: :unprocessable_entity }
end

但是,这不会呈现上面的链接。 我起床了:

http://localhost:3000/abcd/users/microsoft/questions

有什么建议吗?

0 个答案:

没有答案
相关问题