How to add link_to to Div section on ActiveAdmin show page | Rails 4

I have implemented one panel of the active admin page. In this panel, I show a list of data loop

. Here's 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 an 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 link to each 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 putting link_to

in the next line. But in this case, only the link is not displayed above the content.

Where am I going wrong. Could you please point me. I already link to http://activeadmin.info/docs/6-show-pages.html but am not getting any solution.

+3


source to share


1 answer


You can write the 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

      

+2


source







All Articles