Reputation: 8461
I'm trying to basically update my integration object attribute "filters". I have a integrations controller and what seems the proper actions to do so. But when I try to save after filling out the text-field I get this error No route matches [POST]
, I understand what it's saying but isn't update a post? Here is my code for clarity.
def update
@integrations = current_account.integrations.find(params[:id])
attrs = params.require(:integration).permit(:filters)
if @integrations.update_attributes(attrs)
redirect_to account_integration_path
else
render :filters
end
end
def filters
@integrations = current_account.integrations.find(params[:id])
end
<%= form_for @integrations, url: filters_account_integration_path do |f| %>
<%= f.text_field :filters, class: "tag-autocomplete" %>
<%= link_to "Save", account_integration_path, method: :post, class: [ "button", "button--modal" ] %>
<% end %>
resources :integrations, only: [ :index, :destroy, :update ] do
get "filters", on: :member
end
Hopefully that is enough info let me know if you need more? My basic question is why is this not updating the integration object? Isn't update a post?
Upvotes: 0
Views: 402
Reputation: 5712
resources
generates seven routes by default. You're using it to generate only three of those. Those three routes will look like this:
GET /integrations
DELETE /integrations/:id
PATCH /integrations/:id/edit
Your form, on the other hand, is trying to use this route:
POST /integrations/:id
which doesn't match any of the generated routes.
Instead, try using the default form helpers:
<%= form_for @integrations, url: url_for(:controller => :integrations, :action => :update, :id => @integrations.id) do |f| %>
<%= f.text_field :filters, class: "tag-autocomplete" %>
<%= f.submit "Save" %>
<% end %>
That's assuming that @integrations
is a single Integration
resource. If it isn't, you have bigger problems than just this.
Upvotes: 1