How to add link_to under Div on ActiveAdmin's show page | Rails 4

687 views Asked by At

I have implemented one panel of Active Admin's show page. In this panel I am showing list of data by loop. Here is what I did:

 show do
  default_main_content
  panel "Best #{trip_type.camelize} (Live)" do
    live_datas1.each do |live|
      div do
        live["outbound_date"].strftime('%A')+ ", " + live["outbound_date"].strftime('%Y-%m-%d') + " To " + live["inbound_date"].strftime('%A') + ", " + live["inbound_date"].strftime('%Y-%m-%d') + " = " + flight.currency_symbol + live["price"] 
      end
    end
  end
 end

Which gives me output like:

Best Shortbreak (Live)
Monday, 2015-08-10 To Wednesday, 2015-08-12 = £716.0
Monday, 2015-08-03 To Wednesday, 2015-08-05 = £761.0
Wednesday, 2015-08-12 To Friday, 2015-08-14 = £806.0
Wednesday, 2015-08-19 To Friday, 2015-08-21 = £876.0

Now I want to add one linke on every end of the line:

Monday, 2015-08-10 To Wednesday, 2015-08-12 = £716.0 [Link]

for this I add

live["outbound_date"].strftime('%A')+ ", " + live["outbound_date"].strftime('%Y-%m-%d') + " To " + live["inbound_date"].strftime('%A') + ", " + live["inbound_date"].strftime('%Y-%m-%d') + " = " + flight.currency_symbol + live["price"] + link_to "Link", "#"

also try to put link_to in next line. But in this case above content is not displayed only link appear.

Where I do mistake. Can you please point me. I have already refer this http://activeadmin.info/docs/6-show-pages.html but not get any solution.

1

There are 1 answers

0
Sarwan Kumar On BEST ANSWER

You can write following code instead, and it will work fine.

show do  
  default_main_content  
  panel "Best #{trip_type.camelize} (Live)" do  
    live_datas1.each do |live|  
      div do
        "#{live["outbound_date"].strftime('%A')}, #{live["outbound_date"].strftime('%Y-%m-%d')} To #{live["inbound_date"].strftime('%A')}, #{live["inbound_date"].strftime('%Y-%m-%d')} = #{flight.currency_symbol}#{live["price"]} [#{link_to "Link", "#"}]".html_safe
      end
    end  
  end
end