Displaying 3 results from an estimated 3 matches for "employer_id".
Did you mean:
employee_id
2006 Jul 19
2
SimplyRestful bug?
Hi I have my routes set up like this:
map.resource :contact, :path_prefix => "/employers/:employer_id"
so now when I view all contacts for an employer I go to:
/employers/1/contacts
That works. On that page, there''s a problem with the routes:
new_contact_url translates to: /employers/1/contacts/new ... so that
works.
But, contact_url(@contact) gives me /employers/3/contacts .......
2012 Mar 02
0
ConnectionNotEstablished when using connection on AR::Base abstract subclass
...stablish_connection(:adapter => "sqlite3",
:database => "./db.sqlite")
DB.connection.create_table(:employers) do |t|
t.primary_key :id
end
DB.connection.create_table(:employees) do |t|
t.primary_key :id
t.integer :employer_id
end
Employer.create!.employees << Employee.create!
Employer.all.each do |employer|
p employer.employees
end
Output:
D, [2012-03-02T16:22:36.852779 #14148] DEBUG -- : (1.7ms)
select sqlite_version(*)
D, [2012-03-02T16:22:36.854577 #14148] DEBUG -- : (1.3...
2006 Jul 17
14
REST Relationship Models
I''m trying to figure out an elegant way to do this:
I have the following three tables:
people, employer, employees
And consequently the following three models:
class Person < ActiveRecord::Base
end
class Employer < ActiveRecord::Base
has_many :employees
end
class Employee < ActiveRecord::Base
belongs_to :person
belongs_to :employer
end
I want to be able to say: