undefined方法`member_trips_path'在ruby app中

时间:2014-07-29 02:57:40

标签: ruby-on-rails ruby devise crud

我正在构建一个应用程序,成员可以创建一个旅行,我正在使用设计宝石进行授权。 当会员登录时,他们会被重定向到有表格的旅行新页面。出于某种原因,我无法正确地获得表单语法,而且我遇到了一个错误:未定义的方法`member_trips_path'

这是旅行新表格

<%= form_for [current_member, @trip] do |f| %> 

<%= f.label :where, "Where?" %><br/>
<%= f.text_field :where, placeholder: "Hawaii" %><br>

<%= f.label :when, "When?" %><br/>
<%= f.text_field :when, placeholder: "#" %><br>

<%= f.label :price_per_person, "Price per person? (Approximately)" %><br/>
<%= f.text_field :price_per_person, placeholder: "$550" %><br>

<%= f.submit "Create Trip Idea"%>
<% end %>

当前成员相当于@member(这是设计宝石所做的)

rake routes

       member_trip_index GET    /members/:member_id/trip(.:format)          trip#index
                       POST   /members/:member_id/trip(.:format)          trip#create
       new_member_trip GET    /members/:member_id/trip/new(.:format)      trip#new
      edit_member_trip GET    /members/:member_id/trip/:id/edit(.:format) trip#edit
           member_trip GET    /members/:member_id/trip/:id(.:format)      trip#show
                       PATCH  /members/:member_id/trip/:id(.:format)      trip#update
                       PUT    /members/:member_id/trip/:id(.:format)      trip#update
                       DELETE /members/:member_id/trip/:id(.:format)      trip#destroy

行程控制器

class TripController < ApplicationController
def index
end

def new
    @trip = Trip.new 
end

def create
end
end

1 个答案:

答案 0 :(得分:2)

您的路由错误 - 我认为您已定义类似resources :trip的内容,应该是resources :trips。在路由中混合单数和复数是危险的,并导致奇怪的错误。