I am using a Gem to communicate with FreeagentCentral via their API. I have the following code to display a link to the relevant freeagent project:
<%= link_to "#{image_tag('/images/icons/Spinning Beach Ball.png')} Freeagent Project", "#{Freeagent::Base.site.to_s + Freeagent::Project.element_path(@kase.freeagent_id).gsub(/\A\//, '').gsub!(/.xml/,'')}" if @kase.freeagent_id %>
The problem – There is a / omitted from the URL which makes the url like this:
https://XXXXX.freeagentcentral.comprojects/12345
where it should be:
https://XXXXX.freeagentcentral.com/projects/12345
This may be simple, but to me – it’s driving me crazy!
Thanks,
Danny
I’m assuming that
Freeagent::Base.siteis retuning'https://XXXXX.freeagentcentral.com'. In which case, you just need to add the/into your string between the site and project parts. Try the following:Edit:
Looking at this more closely,
gsub(/\A\//, '')is removing a/from the start of the string returned byFreeagent::Project.element_path(@kase.freeagent_id). Assuming thatelement_pathdoes actually return a string with a leading/, the better answer would be to remove the firstgsubcall: