当前页面?具有不同控制器和动作的方法

时间:2014-10-11 17:56:55

标签: ruby-on-rails ruby-on-rails-4

我正在使用current_page?方法追加“活跃的”#39;到我的导航链接周围的li标签。 current_page?还允许我处理子菜单中的活动链接。侧边栏包含指向整个应用程序中不同控制器和操作的链接。但是,单击侧栏中的最后一个链接(link_to edit_lender_registration_path)我收到以下错误:

  

没有路线匹配{:action =>" dashboard",   :控制器=>"贷方/ lender_account"}

我不确定它从:controller=>"lenders/lender_account"到哪里。我还没有在任何if语句中指定控制器。

我的_sidebar.html.erb:

<!-- Begin Sidebar Menu -->
<div class="col-md-3" id="small">
  <ul class="list-group sidebar-nav-v1" id="sidebar-nav">
    <% if current_page?(controller: 'lender_account', action: 'dashboard') %>
      <li class="list-group-item active">
    <% else %>
      <li class="list-group-item">
    <% end %>
        <%= link_to root_path do %>
          <i class="fa fa-dashboard"></i> My Account
        <% end %>
      </li>
    <% if current_page?(controller: 'lender_account', action: 'pending_loans') %>
      <li class="list-group-item active">
    <% else %>
      <li class="list-group-item">
    <% end %>
        <%= link_to pending_loans_path do %>
          <i class="fa fa-refresh"></i> Pending Loans
        <% end %>
      </li>
    <% if current_page?(controller: 'lender_account', action: 'portfolio') %>
      <li class="list-group-item active">
    <% else %>
      <li class="list-group-item">
    <% end %>
        <%= link_to portfolio_path do %>
          <i class="fa fa-folder"></i> Loan Portfolio
        <% end %>
      </li>
    <% if current_page?(controller: 'lender_account', action: 'loan_payments') %>
      <li class="list-group-item active">
    <% else %>
      <li class="list-group-item">
    <% end %>
        <%= link_to loan_payments_path do %>
          <i class="fa fa-money"></i> Loan Payments
        <% end %>
      </li>

      <!-- Sub menu -->
      <li class="list-group-item list-toggle">
        <a data-toggle="collapse" data-parent="#sidebar-nav" href="#collapse-transactions"><i class="fa fa-exchange"></i> Transactions</a>
        <ul id="collapse-transactions" class="collapse">
          <li><%= link_to "Overview", overview_lender_transaction_path(current_user) %></li>
          <li><%= link_to "Deposits", deposits_lender_transaction_path(current_user) %></li>
          <li><%= link_to "Withdrawals", withdrawals_lender_transaction_path(current_user) %></li>
          <li><%= link_to "Loan Transactions", loan_transactions_lender_transaction_path(current_user) %></li>
        </ul>
    </li>
    <!-- End Sub menu -->
    <% if current_page?(controller: 'lenders/registrations', action: 'edit') %>
      <li class="list-group-item active">
    <% else %>
      <li class="list-group-item">
    <% end %>
        <%= link_to edit_lender_registration_path do %>
          <i class="fa fa-user"></i> Account Settings
        <% end %>
      </li>
  </ul>
</div>
<!-- End Sidebar Menu -->

适用的路线:

  devise_for :users, skip: :registrations do get '/users/sign_out' => 'devise/sessions#destroy' end
  devise_for :lenders, skip: :sessions, :controllers => {:registrations => "lenders/registrations"}
  devise_for :businesses, skip: :sessions, :controllers => {:registrations => "businesses/registrations"}

    resources :businesses, :only => [] do
        resource :supp_form
        resource :loan_application
    end 

    resources :lenders, :only => [] do
        resource :loan_part
        resource :transaction do
            get :overview, :on => :collection
            get :deposits, :on => :collection
            get :withdrawals, :on => :collection
            get :loan_transactions, :on => :collection
        end 
    end

    # Lender Routes
    get 'portfolio', to: 'lender_account#portfolio'
    get 'balances', to: 'lender_account#balances'
    get 'pending_loans', to: 'lender_account#pending_loans'
    get 'loan_payments', to: 'lender_account#loan_payments'
    match '/accounts/:id', to: 'lender_account#dashboard', :as => 'account', via: [:get]

0 个答案:

没有答案