ActionView :: Template ::错误未定义的局部变量或方法`href'

时间:2012-12-03 03:54:28

标签: ruby-on-rails-3 routing ruby-on-rails-3.2

为什么我的rails应用程序会因任何需要路由的操作而引发错误?

这是我得到的:

ActionView::Template::Error (undefined local variable or method `href' for #<#<Class:0xaba4f00>:0xafd636c>):

对于任何link_to,可能是什么错误?,我将routes.rb还原为一个好的版本,但是,我仍然有问题..

有什么想法吗?

修改

这是我的routes.rb

DCACLab2::Application.routes.draw do

  resources :authentications

  resources :class_rooms_member_ships

  resources :lessons

  resources :subscriptions
  resources :plans


  resources :schools




  #match '/:id' => 'class_rooms_member_ships#new', :constraints => { :id => /\d+/ }

  devise_for :users, :controllers => {  :registrations => "users/registrations" } # :sessions => "users/sessions",


  resources :teacher_profiles do
    get :autocomplete_school_name, :on => :collection
  end
  resources :experiments
  get 'experiments/:id/info_edit' => 'experiments#info_edit',:constraints => { :id => /\d+/ }

  Rails.application.routes.draw do


    resources :teacher_profiles

    resources :schools

    filter :locale, :pagination, :uuid
  end


  match 'lang' => 'home#set_lang'

  match 'free_trial' => 'home#free_trial'
  match 'home' => 'home#home'
  match 'features' => 'home#features'
  match 'pricing' => 'home#pricing'

  match 'contact' => 'contact#new', :as => 'contact', :via => :get
  match 'contact' => 'contact#create', :as => 'contact', :via => :post

  match 'dashboard' => 'experiments#index'
  match 'complete_order' => 'home#complete_order'
  post 'notifications' => 'subscriptions#instant_payment_notification'
  get 'paypal/checkout', to: 'subscriptions#paypal_checkout'
  get 'paypal/checkout/post/form', to: 'subscriptions#paypal_checkout_post_form'

  #match 'lab' => 'home#lab'
  match 'lab' => 'experiments#lab'


  match 'trial_account' => 'home#trial_account'
  match 'student_account' => 'home#student_account'
  match 'school_account' => 'home#school_account'


  match 'create_account' => 'home#registration_entrance'
  match 'users/create_account' => 'home#registration_entrance'
  match 'registration_redirect' => 'home#registration_redirect', :via=>[:post]
  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  root :to => 'home#home'

  match '/auth/facebook/logout' => 'authentications#facebook_logout', :as => :facebook_logout
  #match '/auth/facebook/callback' => 'authentications#create'
  match '/auth/:provider/callback' => 'authentications#create'
  match '/auth/failure' => 'authentications#failure'

  match '/fb_channel', :controller=>'authentications', :action=>'fb_channel'


end

至于link_to代码,它只是正常..

%li{:class=>"#{action_name == action ? 'active':''}"}
                 = link_to :controller => '/home', :action => action do
                   = t(action)

0 个答案:

没有答案