Rails路由不在生产中工作

时间:2015-06-16 08:45:46

标签: ruby-on-rails

不确定这里发生了什么。这在开发中完美地工作并且在生产中引发错误。 Rake路由显示每个环境中的路径与dashboard_path相同。 Ruby版本和rails版本在两者中都是相同的。我重新启动了服务器,重新初始化了unicorn,bundle,db:reset,两个环境中的所有东西。我把头发拉了出来。

错误消息

I, [2015-06-16T03:31:50.600950 #12311]  INFO -- :   Rendered pages/index.html.erb within layouts/application (17.7ms)
I, [2015-06-16T03:31:50.601165 #12311]  INFO -- : Completed 500 Internal Server Error in 24ms
F, [2015-06-16T03:31:50.603417 #12311] FATAL -- : 
ActionView::Template::Error (undefined method `dashboard_path' for #<#    <Class:0x000000052151b0>:0x00000004c35448>):
    1: <td>
    2:   <%= link_to page.name, dashboard_path(page) %>
    3: </td>
    4: <td id="page_select_form">
    5:   <% if page.group.nil?%>
  app/views/pages/_page.html.erb:2:in `_app_views_pages__page_html_erb__2539077092639507273_42387000'
  app/views/pages/index.html.erb:19:in `block in _app_views_pages_index_html_erb___1631868800231267778_43030140'
  app/views/pages/index.html.erb:17:in `_app_views_pages_index_html_erb___1631868800231267778_43030140'

index.html.erb

  <div class="container">
  <div class="row">
    <h3 class="std-heading">Pages</h3>
    <h4 class="std-create"><%= link_to "Create Page", new_page_path %></h4>
    <div class="column">
      <table class="table">
        <tbody>
         <% if current_company.pages.empty? %>
           <p>It looks like you don't have any pages yet. Create one <%= link_to 'here!', new_page_path %></p>
         <% else %>
            <tr class="firstrow">
                <td><b>Name</b></td>
                <td><b>Assigned Group</b></td>
                <td></td>
                <td></td>
            </tr>
          <% current_company.pages.each do |page| %>
                <tr>
                  <%= render page %>
                </tr>
            <% end %>
          <% end %>
        </tbody>
      </table>
     <hr>
    </div>
  </div>
</div>

和部分

<td>
  <%= link_to page.name, dashboard_path(page) %>
</td>
<td id="page_select_form">
  <% if page.group.nil?%>
    <p>Unassigned</p>
  <% else %>
    <%= simple_form_for page do |f| %>
        <%= f.input :group_id, collection: @groups, 
            select: page.group, 
            label: false, 
            include_blank: false %>
    <%= f.submit :submit, class: "btn" %>
    <% end %>
  <% end %>
</td>
<td>
  <%= link_to 'Edit Page', page %>
</td>
<td>
  <%= link_to("Delete Page", page_path(page), 
    :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'button-xs') %>
</td>

的routes.rb

get '/pages/:id/dashboard', to: 'pages#dashboard', as: :dashboard

以下是生产相关的佣金路线(与开发相同)

 mercury_update_page POST   /pages/:id/mercury_update(.:format) pages#mercury_update
               pages GET    /pages(.:format)                    pages#index
                     POST   /pages(.:format)                    pages#create
            new_page GET    /pages/new(.:format)                pages#new
           edit_page GET    /pages/:id/edit(.:format)           pages#edit
                page GET    /pages/:id(.:format)                pages#show
                     PATCH  /pages/:id(.:format)                pages#update
                     PUT    /pages/:id(.:format)                pages#update
                     DELETE /pages/:id(.:format)                pages#destroy
                     PUT    /pages/:id/mercury_update(.:format) pages#mercury_update
              groups GET    /groups(.:format)                   groups#index
                     POST   /groups(.:format)                   groups#create
           new_group GET    /groups/new(.:format)               groups#new
          edit_group GET    /groups/:id/edit(.:format)          groups#edit
               group GET    /groups/:id(.:format)               groups#show
                     PATCH  /groups/:id(.:format)               groups#update
                     PUT    /groups/:id(.:format)               groups#update
                     DELETE /groups/:id(.:format)               groups#destroy
  groups_select_page POST   /groups/select_page(.:format)       groups#select_page
                     GET    /q/:path(.:format)                  q_rcodes#new
                     GET    /t/:path(.:format)                  tags#processurl
                     GET    /pages/view/:path(.:format)         pages#view
           dashboard GET    /pages/:id/dashboard(.:format)      pages#dashboard
                home GET    /home(.:format)                     home#index

请帮忙!

1 个答案:

答案 0 :(得分:0)

尝试更改<div class="input-group input-group-sm date-time-with-arrows" style="width:100%"> <span class="input-group-btn"> <button class="btn btn-default" ng-click="prevDay()"> <i class="fa fa-angle-left "></i></button> </span> <div id="input" class="input-group input-group-sm nested-group" ng-model="model"> <input class="form-control input-sm" ng-disabled="disabled" type="text" ng-attr-placeholder="{{configuration.noSelectionLabel}}" /> <span class="input-group-btn after-date-input"> <button class="btn btn-default pick-cal" ng-disabled="isDisabled" type="button"> <span class="glyphicon glyphicon-calendar"></span> </button> </span> </div> <span class="input-group-btn after-date-input"> <button class="btn btn-default" ng-click="nextDay()"> <i class="fa fa-angle-right"></i></button> </span> </div>

中的这一行
index.html.erb

<%= render page %>

注意: 在Rails中命名文件时要小心。在您的情况下,您的模型名称和视图页面名称(<%= render partial: "page", locals: { page: page } %> )具有相同的名称(页面),这足以混淆Rails。

<强> 更新

尝试传递其他实例。可能实例(页面)模型(页面)

冲突

_page.html.erb中,进行这些更改

index.html.erb

<% current_company.pages.each do |company_page| %> <tr> <%= render partial: "page", locals: { company_page: company_page } %> </tr> <% end %>

更改此行

_page.html.erb

<%= link_to page.name, dashboard_path(page) %>