Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL request problem #84

Open
jsaray opened this issue Aug 29, 2014 · 0 comments
Open

SQL request problem #84

jsaray opened this issue Aug 29, 2014 · 0 comments

Comments

@jsaray
Copy link

jsaray commented Aug 29, 2014

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 :

[{"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 ?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant