Ruby on rails 3 在具有嵌套atributes但没有默认操作的窗体上没有路由匹配

Ruby on rails 3 在具有嵌套atributes但没有默认操作的窗体上没有路由匹配,ruby-on-rails-3,forms,Ruby On Rails 3,Forms,我有一个表单来更新一个名为post的项目,但是我需要一个不同于update的方法,因为更新post有两种方法,我已经尝试了很多方法,但是我只得到了这个错误 没有路线匹配“/主题/1/帖子/35/完成” 控制员: def completed @post.download_remote_image respond_to do |format| if @post.save format.html { redirect_to topic_path(@top

我有一个表单来更新一个名为post的项目,但是我需要一个不同于update的方法,因为更新post有两种方法,我已经尝试了很多方法,但是我只得到了这个错误

没有路线匹配“/主题/1/帖子/35/完成”

控制员:

  def completed
    @post.download_remote_image
    respond_to do |format|
      if @post.save
        format.html { redirect_to topic_path(@topic), :notice => t('.post_created') }
      else
        format.html { render :action => :edit }
      end
    end
  end
视图部分:

= form_for [@topic, @post], :url => completed_topic_post_path(@topic, @post) do |f|
路线:

  resources :topics do
    resources :posts do
        get 'complete', :as => :complete
        post 'completed', :as => :completed
    end
  end

谢谢

:url=>完成的主题帖子路径(@topic,@post)需要是:url=>主题帖子完成的帖子路径(@topic,@post)

键入rake路由并发布您获得的结果:更改:url=>完成的主题帖子路径(@topic,@post)为:url=>完成的主题帖子路径(:topic id=>@topic.id,:post id=>@post.id)同样,通过您的资源定义,我从rake路由中获得以下输出:topic_post_completed post/topics/:topic_id/posts/:post_id/completed(:format){:action=>“completed”,:controller=>“posts”}我找到了解决方案,问题在于rails的魔力,使用form_标记而不是form_来节省时间。