Ruby on rails Ruby错误未初始化常量
我只是从RubyonRails开始,并遵循 在某一点上,我犯了一个错误Ruby on rails Ruby错误未初始化常量,ruby-on-rails,ruby,Ruby On Rails,Ruby,我只是从RubyonRails开始,并遵循 在某一点上,我犯了一个错误 Showing /home/ubuntu/workspace/app/views/cities/_form.html.haml where line #26 raised: uninitialized constant City::Direction 并指出: .col-md-6 %h3 How to get There ? #getthere
Showing /home/ubuntu/workspace/app/views/cities/_form.html.haml where line #26 raised: uninitialized constant City::Direction
并指出:
.col-md-6
%h3 How to get There ?
#getthere
= f.simple_fields_for :directions do |direction|
= render 'direction_fields', :f => direction
.links
= link_to_add_association 'Add Directions', f, :directions, class: "btn btn-default add-button"
我不知道去哪里找,据我所知,我的数据库创建得很好。有人能帮我吗
我有这个数据库
class CreateDirections < ActiveRecord::Migration
def change
create_table :directions do |t|
t.text :getthere
t.belongs_to :city, index: true
t.timestamps
end
end
end
还有这个
class CreateCities < ActiveRecord::Migration
def change
create_table :cities do |t|
t.string :title
t.text :description
t.integer :user_id
t.timestamps
end
end
end
这个城市模型呢
class City < ActiveRecord::Base
has_many :infos
has_many :directions
accepts_nested_attributes_for :infos, reject_if: proc { |attributes| attributes['information'].blank? },
allow_destroy: true
accepts_nested_attributes_for :directions, reject_if: proc { |attributes| attributes['getthere'].blank? },
allow_destroy: true
validates :title, :description, :image, presence: true
has_attached_file :image, :styles => { :medium => "163x163#"}
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end
哦,对不起。让我再看一看,你是不是想迁移??第26行是什么?你们有方向模型吗?它应该放在app/models/direction.rb文件中。是的,这是在It类Directions