自定义rails路由不像我期望的那样路由

时间:2014-01-01 00:31:38

标签: ruby-on-rails-3 devise

我有一个jquery,我网站上的每个人都可以点击更新他们的订阅,如下所示

<div id="role-options-<%= current_user.id %>" class="modal modalSubscription" style="display: none;">
  <%= simple_form_for current_user, :url => user_path(current_user), :html => {:method => :put, :class => 'form-horizontal' } do |f| %>

...Form stuff

  <div class="modal-footer">
    <%= f.submit "Update Settings", :class => "btn btn-green" %>
    <a class="btn btn-green closeModal" data-dismiss="modal" href="#">Close</a>
  </div>
 <% end %>
</div>

我正在尝试将其推送到自定义路由,这是一个更新订阅路径。我正在使用设计。在一个完美的世界中,我想将它发送到一个标记为SubscriptionsController的独立控制器,以便它可以处理更新操作。我在路线上尝试了很多东西

#I expected this to send the request to the subscription controller after i changed the :url to update_subscriptions_path, but it did not
 put "/users/update_subscription", :to => 'subscription#update'

我还尝试在控制器中添加“update_subscription”方法,并将表单中的url设置为     users_update_subscription_path

然而,这已发布到更新路径

1 个答案:

答案 0 :(得分:0)

好吧就是犯了一个错误,我添加的路径是在资源之后:用户,看起来像rails看到了put请求并自动假设我想要更新用户并且没有让它变成额外的路径我补充说。