开发者

No Route matches on Form with nested atributes but not default action

开发者 https://www.devze.com 2023-03-22 17:34 出处:网络
I have a form to update an item called post, but i need a different method than开发者_如何学Python update because there are 2 ways to update the post, i have tried this in a lot of ways but i only get

I have a form to update an item called post, but i need a different method than开发者_如何学Python update because there are 2 ways to update the post, i have tried this in a lot of ways but i only get this error

No route matches "/topics/1/posts/35/completed"

the controller:

  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

the view part:

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

the routes:

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

Thanks !!


:url => completed_topic_post_path(@topic, @post) needs to be :url => topic_post_completed_path(@topic, @post)

0

精彩评论

暂无评论...
验证码 换一张
取 消