为什么我会收到错误消息:StaticPagesController #index中的NoMethodError

时间:2015-11-15 01:27:39

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

当我在rails程序上运行ruby时,会收到错误消息:undefined method`action' for StaticPagesController:Class

application_controller.rb

require_relative '../models/pet'

class ApplicationController < Sinatra::Base


  get '/' do
    #home
    erb :index
  end
  get '/questions' do
    erb :questions
  end
post '/results' do 
  @dog=get_results(params)

  erb :results
end
end

这是我的static_pages_controller.rb

class StaticPagesController < ApplicationController

  def index
     # Renders static_pages/swalton2html.erb by default.
  end

   def questions
    # Renders static_pages/swalton2html.erb by default.
  end

1 个答案:

答案 0 :(得分:0)

看来你可以从阅读Ruby on Rails的getting started guide中受益。

基本上,您的控制器结构,路由和(可能)视图对您的影响比对您的影响更大。使用Rails生成器来查看应该如何组织事情可能会有所帮助。