我自己在ruby中的路线问题

时间:2018-06-01 22:19:19

标签: ruby-on-rails

我在我的控制器上创建了一个方法(admin / highlight_controller),如下所示:

def process
    @checkIfExists =  Highlight.where(year: params[:year], highlight_category:params[:highlight_category])

    if @checkIfExists.count > 0
      redirect_to admin_highlight_path(@checkIfExists.first)  
    else
      redirect_to new_admin_highlight_path(year: params[:year], highlight_category:params[:highlight_category])
    end
end

在我创建的路线中:

get '/admin/highlight', to: 'admin/highlights#process', as: 'highlights_process'

在另一个视图中,我想链接到我创建的这个方法,我这样做:

<%= link_to year.year, highlights_process(year: year.id, highlight_category: highlight_category.id) %>

但是我收到了这个错误:

undefined method `highlights_process' for #<#<Class:0x007faee6309bb0>:0x007faee7813d30>

我做错了什么?当我做一个rake路线时,我得到了正确创建的路线。

   highlights_process GET    /admin/highlight(.:format) admin/highlights#process                                      

0 个答案:

没有答案