You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using your gem, I have the following class structure
MIGRATIONS ==============================
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.string :personible_type
t.integer :personible_id
t.string :name, null: false
t.string :email, null: false
t.string :phone
t.string :picturepath
t.timestamps
end
end
end
class CreateGuides < ActiveRecord::Migration
def self.up
create_table :guides do |t|
t.integer :person_id
t.integer :price, null: false
t.integer :reputation
t.timestamps
end
add_foreign_key :guides,:people
end
end
MODELS=======================
class Person < ActiveRecord::Base
acts_as_superclass
end
class Guide < ActiveRecord::Base
acts_as :person, :as => :personible
has_many :availabilities
end
In Guides controller, I have the following statement
result = Guide .where("name = ?",name)
This query gives the following console output :
SELECT guides.id AS t0_r0, guides.person_id AS t0_r1, guides.price AS t0_r2, guides.reputation AS t0_r3, guides.created_at AS t0_r4, guides.updated_at AS t0_r5, people.id AS t1_r0, people.personible_type AS t1_r1, people.personible_id AS t1_r2, people.name AS t1_r3, people.email AS t1_r4, people.phone AS t1_r7, people.picturepath AS t1_r8, people.created_at AS t1_r9, people.updated_at AS t1_r10 FROM guides INNER JOIN people ON people.personible_id = guides.id AND people.personible_type = 'Guide' WHERE (name = 'Jhon')
So the SQL statement is ok. however in the object retrieved in the controller I get :
Hi, I am using your gem, I have the following class structure
MIGRATIONS ==============================
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.string :personible_type
t.integer :personible_id
t.string :name, null: false
t.string :email, null: false
t.string :phone
t.string :picturepath
t.timestamps
end
end
end
class CreateGuides < ActiveRecord::Migration
def self.up
create_table :guides do |t|
t.integer :person_id
t.integer :price, null: false
t.integer :reputation
t.timestamps
end
add_foreign_key :guides,:people
end
end
MODELS=======================
class Person < ActiveRecord::Base
acts_as_superclass
end
class Guide < ActiveRecord::Base
acts_as :person, :as => :personible
has_many :availabilities
end
In Guides controller, I have the following statement
result = Guide .where("name = ?",name)
This query gives the following console output :
SELECT
guides
.id
AS t0_r0,guides
.person_id
AS t0_r1,guides
.price
AS t0_r2,guides
.reputation
AS t0_r3,guides
.created_at
AS t0_r4,guides
.updated_at
AS t0_r5,people
.id
AS t1_r0,people
.personible_type
AS t1_r1,people
.personible_id
AS t1_r2,people
.name
AS t1_r3,people
.email
AS t1_r4,people
.phone
AS t1_r7,people
.picturepath
AS t1_r8,people
.created_at
AS t1_r9,people
.updated_at
AS t1_r10 FROMguides
INNER JOINpeople
ONpeople
.personible_id
=guides
.id
ANDpeople
.personible_type
= 'Guide' WHERE (name = 'Jhon')So the SQL statement is ok. however in the object retrieved in the controller I get :
[{"id":1,"person_id":null,"price":40,"reputation":null,"created_at":"2014-08-23T08:09:06.000Z","updated_at":"2014-08-23T08:09:06.000Z"},{"id":2,"person_id":null,"price":321,"reputation":null,"created_at":"2014-08-23T12:28:38.000Z","updated_at":"2014-08-23T12:28:38.000Z"}]
As you can see the person parameters (name,email,phone etc) are not being retrieved.
Any clues ?.
The text was updated successfully, but these errors were encountered: