When I enter the name of a ActiveRecord class to irb, the schema of the
record is displayed:
Art
Art(id: integer, name: string, created_at: datetime, updated_at:
datetime)
How to query that vir ruby code?
When I enter the name of a ActiveRecord class to irb, the schema of the
record is displayed:
Art
Art(id: integer, name: string, created_at: datetime, updated_at:
datetime)
How to query that vir ruby code?
On Aug 12, 12:48 pm, Fritz T. [email protected] wrote:
When I enter the name of a ActiveRecord class to irb, the schema of the
record is displayed:Art
Art(id: integer, name: string, created_at: datetime, updated_at:
datetime)How to query that vir ruby code?
Take a peak at Art.columns
Fred
On Thu, Aug 12, 2010 at 9:48 AM, Fritz T. [email protected]
wrote:
When I enter the name of a ActiveRecord class to irb, the schema of the
record is displayed:
How to query that vir ruby code?
e.g.
Author
=> Authorid: integer, first_name: string, last_name: string, dob:
date, created_at: datetime, updated_at: datetime, genre: string
Author.inspect
=> “Author(id: integer, first_name: string, last_name: string, dob:
date, created_at: datetime, updated_at: datetime, genre: string)”
Hassan S. ------------------------ [email protected]
twitter: @hassan
Thanks for your replies.
Using columns, the name can be queried by human_name:
Art.columns[0].human_name
inspect is perfect for displaying purposes.
Fritz T. wrote:
Thanks for your replies.
Using columns, the name can be queried by human_name:
Art.columns[0].human_name
inspect is perfect for displaying purposes.
Note that, in my experience at least, this is rarely necessary unless
you’re writing something like ActiveScaffold. What are you trying for
here?
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs