Bir uygulamayı Rails 4'e yükseltiyorum ve bu yöntemin nesi yanlış olduğunu anlayamıyorum. Bu gibi görünüyor,Raylar 4: Bu yöntemde sorun nedir?
respond_to do |format|
oluşturmak yöntem çalışıyor: Bu hata
def update
respond_to do |format|
if @doc.articles.find_index { |a| a.changed? }
@doc.publications.destroy_all
end
if @doc.update_attributes(params[:doc])
@doc.create_activity :update, owner: current_user
if current_user.brand.editable? && params[:editing]
format.html { redirect_to editing_url(@doc) }
else
format.html { redirect_to share_url(@doc.user.ftp, @doc) }
end
end
end
end
submit
tıklamak oluşturur:
ActionController::UnknownFormat in DocsController#update
ve olayları bu hat suçlunun güncelleme yöntemi var
def create
@doc = Doc.new(params[:doc])
respond_to do |format|
if @doc.save
@doc.create_activity :create, owner: current_user
if current_user.brand.editable? && params[:editing]
format.html { redirect_to doc_editing_url(@doc) }
else
format.html { redirect_to share_url(@doc.user.ftp, @doc) }
end
else
format.html { render action: "new" }
end
end
end
Hiç bir fikrin var mı? Tamamen sıkışmışım.
Ah, ben de bir before_action
olarak bu özel yöntemi var, bu yüzden o değil:
: Bu yarı-açıklamayı buldumIn Rails 4.0, ActionController::UnknownFormat is raised when the action doesn't handle the request format. By default, the exception is handled by responding with 406 Not Acceptable, but you can override that now. In Rails 3, 406 Not Acceptable was always returned. No overrides.
private
def set_document
@doc = Doc.find(params[:id])
end
DÜZENLEME
, bu bana rotalarla ilgili bir şey olduğunu düşündürüyor, ama onları böyle beyan ettiysem, rotalarım varsayılan olmalı, evet?
resources :docs, :except => [:new, :show] do
get "adjust/:state" => "docs#adjust", :as => :adjust
patch "editing" => "docs#editing", :as => :editing
patch "reupdate/" => "docs#reupdate", :as => :reupdate
get "pdf" => "docs#pdf", :as => :pdf
collection { post :sort }
end
DÜZENLEME 2
yani kontrolöre JSON ekleme:
format.html { redirect_to share_url(@doc.user.ftp, @doc) }
format.json { render action: 'share', status: :created, location: @doc }
bana hiçbir yöntem hata veriyor ve düzenleme sayfaya geri beni yönlendirmek gibi görünüyor: Showing .../fin/app/views/docs/_form.html.erb where line #19 raised:
undefined method `covers?' for nil:NilClass
Burada neler olduğu hakkında hiçbir fikrim yok.
Formunuzda 'remote: true' var mı? JS ile gönderilir mi? kontrol cihazınızda "response_to: json" var mı? – phoet
Formda "remote: true" yok ve JS ile gönderilmiyor. Denetleyicimde "response_to: json" yok, çünkü bildiğim kadarıyla buna ihtiyacım yok. –