Ruby on Rails Wednesday, April 23, 2014

I guess I am the only one using it like this, by i regularly start my `rails console` to quickly show the column-names of models. 

Since 4.1 (afaik), the first call to a class does not return the model introspection, but instead urges me to use `Batch.connection` to establish a connection??? 

If I use a specific method to get the column names, I get no error, and afterwards the class introspection just works. 

Of course this is no biggie, but I am curious what the cause is of the this behaviour, whether this is intended or not, and how I could circumvent it. 

Example console output: 

```
Loading development environment (Rails 4.1.0)
 :001 > Batch
 => Batch (call 'Batch.connection' to establish a connection)
 :002 > Batch.column_names
 => ["id", "name", "batch_nr", "revision", "comments", "batch_status_id", "created_at", "updated_at"]
 :003 > Batch
 => Batch(id: integer, name: string, batch_nr: string, revision: string, comments: text, batch_status_id: integer, created_at: datetime, updated_at: datetime)
```

Any tips or hints would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/455dab42-7869-4747-b109-1602841d8393%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment