0
votes

I have 2 tables preorder and payment with has_many relation, I want display the contents in table only after checking the status (boolean) condition, I tried with following code snippet but its not working? How to do check the condition inside the table_for?

  panel "payment" do
    table_for preorder.payments do |a|
      if a.status.nil?
        column "Received On",     :created_at
        column "Details & Notes", :payment_details
        column "Amount",          :amount_in_dollars
      end
    end
  end

Payment model attr_accessible :created_at, :payment_details, :status, :amount_in_dollars belongs_to :preorder

preorder model attr_accessible :name, :order has_many :payments

I want to display the payment details in preorder admin page based on status.

1
Use if a.status instead of if a.status.nil?. - Arup Rakshit
Its throwing error as undefined method 'status' - pbms

1 Answers

1
votes

Try the following code. I hope it works.

panel "payment" do
 table_for preorder.payments do |a|
   unless a.blank?
    if a.status
      column "Received On",     :created_at
      column "Details & Notes", :payment_details
      column "Amount",          :amount_in_dollars
    end
   end
 end
end