开发者

Rails 3 relationship definition problem?

I'm new to Rails 3, i'm creating a web app that use active admin, i get a problem with him, and asked for help inside github plugin, someone told me maybe a relationship definitions.

I really dont know what is that, i have nested elements and in active admin i want to make nested element independent.

but now, im totally lost. what i missed? thanks. here is my model definition

class Company < ActiveRecord::Base
before_save :getsubdomain

has_attached_file :logo, :styles => { :thumb => '150x150>', :medium => '250x250>', :normal => '350x350>'}

has_many :buildin开发者_StackOverflow社区gs
accepts_nested_attributes_for :buildings

end


Building model
class Building < ActiveRecord::Base

belongs_to :companies  

end

in my db, i have colum company_id in buildings table.

Here the error message i get..

NameError in Admin/buildings#index
Showing /Library/Ruby/Gems/1.8/bundler/gems/active_admin-c3a1ffa98072/app/views/active_admin/resource/index.html.arb where line #1 raised:

uninitialized constant Building::Companies

Rails.root: /Users/username/Sites/myapps

Request

Parameters:

{"order"=>"id_desc"}


Response

Headers:

None

thanks for your help


belongs_to expects a singular name. Try

belongs_to :company
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜