Pravin
Pravin

Reputation: 6662

More dry views?

I have a simple index page for clients. Client has 20 fields. I am displaying list of clients in a table. For this I have to write in my views something like:

- @clients.each do |client|
  %tr
   %td=client.name
   %td=client.email
   %td=client.address
   %td=client.phone etc...

I am just curious if I can do it something like

- @clients.each do |client|
  - client do
      %tr
       %td= name
       %td= email
       %td= address
       %td= phone etc...

Upvotes: 1

Views: 63

Answers (1)

Richard Holland
Richard Holland

Reputation: 2683

I think you could do something like

- @clients.each do |client|
  - client.instance_eval do
      %tr
       %td= name
       %td= email
       %td= address
       %td= phone etc...

Upvotes: 2

Related Questions