我有一个名为“详情”的自定义操作。当用户刷新屏幕时,屏幕会尝试呈现“显示”操作。可能是什么导致了这个?如何让刷新重新加载“详细信息”操作?
控制器操作:
def details
@extent = params[:extent]
@label = Label.find(params[:label])
@style = params[:style]
create_question_group
end
def create_question_group
@question_group = []
5.times do
@question_group << Question.new
end
end
查看/问题/ details.html.erb
<% provide(:title, 'New Questions') %>
<% provide(:headerText, "Details for New Questions") %>
<% provide(:headerPic, 'question.png') %>
<%= render 'shared/back-link' %>
<%= render 'shared/headline' %>
<div class="singleOption">
<h3><%= @extent.capitalize %> <%= @style.capitalize %> Questions    Label: <%= @label.name %></h3>
</div>
</br>
<%= form_tag create_group_questions_path do %>
<% @question_group.each_with_index do |question, index| %>
<%= hidden_field_tag "questions[#{index.to_i}][extent]", @extent %>
<%= hidden_field_tag "questions[#{index.to_i}][label_id]", @label.id %>
<%= hidden_field_tag "questions[#{index.to_i}][style]", @style %>
<% @question = question %>
<%= render 'prompt_and_answers', :locals =>{:index => index, :style => @style} %>
</br>
<% end %>
<div class="actions">
<%= submit_tag "Create These Questions" %>
</div>
<% end %>
配置/ routes.rb中
root 'static_pages#home'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/partner', to: 'static_pages#partner'
get '/materials', to: 'static_pages#materials', :as => "materials"
get '/signup', to: 'teachers#new'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :admins
resources :account_activations, only: [:edit]
resources :consultancies, only: [:new, :create, :show, :index]
resources :labels
resources :label_objectives do
post 'update_quantities', on: :collection
end
resources :objective_seminars do
post 'update_pretests', on: :collection
post 'update_priorities', on: :collection
end
resources :objective_students
resources :objectives do
get 'quantities', on: :member
end
resources :password_resets, only: [:new, :create, :edit, :update]
resources :pictures
resources :preconditions
resources :questions do
post 'details', on: :collection
post 'create_group', on: :collection
end
resources :quizzes
resources :ripostes
resources :seminars do
get 'pretests', on: :member
get 'priorities', on: :member
get 'scoresheet', on: :member
get 'student_view', on: :member
end
resources :seminar_students do
get 'removeFromClass', on: :member
put 'ajaxUpdate', on: :member
end
resources :students do
get 'edit_teaching_requests', on: :member
end
resources :teachers
Rake Routes:
details_questions POST /questions/details(.:format) questions#details
create_group_questions POST /questions/create_group(.:format) questions#create_group
questions GET /questions(.:format) questions#index
POST /questions(.:format) questions#create
new_question GET /questions/new(.:format) questions#new
edit_question GET /questions/:id/edit(.:format) questions#edit
question GET /questions/:id(.:format) questions#show
PATCH /questions/:id(.:format) questions#update
PUT /questions/:id(.:format) questions#update
DELETE /questions/:id(.:format) questions#destroy
提前感谢您的任何见解。