에 게시 내 경로입니다 :레일 라우팅 같은 경로 이름 여기에
root :to => 'sites#index'
match 'sites' => 'sites#index'
match 'sites/:site' => 'sites#show'
match 'sites/:site/publish' => 'sites#publish', :via => :get
match 'sites/:site/publish' => 'sites#push', :via => :put
match 'sites/:site/:entity_type' => 'entity#index'
match 'sites/:site/:entity_type/new' => 'entity#new', :via => :get
match 'sites/:site/:entity_type/new' => 'entity#create', :via => :put
match 'sites/:site/:entity_type/:entity_name' => 'entity#edit', :via => :get
match 'sites/:site/:entity_type/:entity_name' => 'entity#update', :via => :put
제가하는 데 문제는 내가의 POST를 할 때 실제로에서 액션 메소드를 호출하지 않습니다 경로를 게시 할 것입니다 모든. 그것은 "게시"(지정 안) entity_type_ 매개 변수로 설정 "한다고 여기
내 폼의 :. 사실<%= form_tag({:controller => 'sites', :action => 'publish'}) do %>
<%= hidden_field_tag 'site', params[:site] %>
<%= submit_tag 'Publish' %>
<% end %>
, 나는 숨겨진 필드를 지정하지 않아도이 작업이 완료 될 때 .
Started POST "/sites/kieransenior/publish" for 127.0.0.1 at 2012-05-14 20:35:48 +0100
Processing by EntityController#index as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bCooYei5XTbfNv4MwXqrYAvBzazdcCZpHr7HufKPcxo=", "site"=>"kieransenior", "commit"=>"Publish", "entity_type"=>"publish"}
Completed 500 Internal Server Error in 1ms
HTML 양식은 (명확성을 위해) 다음과 같습니다 : 내가 공격 할 때 경로의 결과로 이런 것입니다 "게시"
<form accept-charset="UTF-8" action="/sites/kieransenior/publish" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="bCooYei5XTbfNv4MwXqrYAvBzazdcCZpHr7HufKPcxo=" /></div>
<input id="site" name="site" type="hidden" value="kieransenior" />
<input name="commit" type="submit" value="Publish" />
</form>
잘못된 장소로 POST하는 원인은 무엇입니까? 그것은 내 라우팅이되어야합니다, 모양이 올바른지. 푸시에 대한
편집
컨트롤러 액션 : 내 뇌가 망했다면 위의
def push
respond_to do |format|
redirect_to :controller => 'sites', :action => 'show', :site => params[:site]
end
end
스크랩, 도움이 될 것이다. 내가 redirect_to를 거기에 쏟아 부은 것처럼 보이고 respond_to를 제거하지 않은 것 같습니다. 오케이.
리디렉션이 작동하지 않는 경우를 사용하여 작동합니다. URL은 동일하게 유지되지만 명령 프롬프트에 다음과 같은 내용이 표시됩니다. Started POST "/ sites/kieransenior/publish"on 127.0.0.1 2012-05-14 20:54:05 +0100 SitesController에 의한 처리 # push as HTML 매개 변수 : http : // localhost :로 리디렉션 됨 { 3000/sites/kieransenior 완료 406 9ms에서 허용되지 않음 (ActiveRecord : 0.0ms) – Kezzer
컨트롤러가 'push'메소드와 어떤 유사점이 있습니까? 일반적으로 '406'은 컨트롤러가 어떤 이유로 게시를 거부하고 있음을 의미합니다. –
원래 게시물을 수정했습니다. 사실, 일치하지 않고 가져 오기/보내기를 사용하면 다른 양식에 대한 업데이트가 작동하지 않습니다. – Kezzer