In a rails application, I have a base model like this :
class User < ActiveRecord::Base
attr_accessible :email, :name
end
And an inheritance from this model, like this :
class Provider < User
belongs_to :user
attr_accessible :business_name, :contact_name, :business_phone_number,
:business_email, :website, :user_id
end
When I do :
Provider.new.user_id
It say NoMethodError: undefined method 'user_id' for #<Provider:0x007f63ec8b3790>
.
When I just do Provider.new
I have this:
#<Provider id: nil, name: nil, email: nil, created_at: nil, updated_at: nil, type: "Provider">
This is a part of my schema.rb :
create_table "providers", :force => true do |t|
t.string "business_name", :null => false
t.string "contact_name", :null => false
t.string "business_phone_number", :null => false
t.string "business_email", :null => false
t.string "website"
t.integer "user_id"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
As you can see, the attributes accessibles for Provider are not accessible. Do you have a solution?
Thanks!