US +1 650 600 3955 | EU +43 720 115 215 office@7sheep.net

3 tips to write better Rails URL helpers

This is a typical Rails URL helper I write these days, and I encourage you to do the same. Why? Let me explain it here, but first the helper: module PostsHelper module_function def post_path_with_date(post, **options) Rails.application.routes.url_helpers.post_path( permalink: post.permalink, year: post.published_on.strftime('%Y'), month: post.published_on.strftime('%m'), day: post.published_on.strftime('%d'), **options ) end end 1234567891011 module PostsHelper   module_function def post_path_with_date(post, **options)     Rails.application.routes.url_helpers.post_path(       permalink: post.permalink,       year: post.published_on.strftime('%Y'),       month: post.published_on.strftime('%m'),       day: post.published_on.strftime('%d'),       **options     )   end end # module_function By using Ruby’s module_function you can create a global helper which can be called like PostsHelper.post_path_with_date(post). This allows you to use this helper outside its typical context, but without breaking existing functionality. Your views will still work, and you can use your helper inside Rails console or any Rake task as well. Win-win! # routes.url_helpers Rails’ magic does a lot for you helping to write as little code as necessary. For example, it mixes all your url helpers into your view context. But once you step out of this context, a lot of the magic is gone. Be sure to always access your urls with Rails.application.routes.url_helpers to be safe from any unpleasant surprises. # kwargs or keyword arguments are my personal favourite of Ruby 2.0. And if you’re already using a recent version (and you really should so), don’t hesitate to use them already now. By passing the given kwargs to the route helper, you can easily customize your routes for your needs. For example, the other day I needed all blog post URLs including our domain: Post.all.map { |p| PostsHelper.post_path_with_date(p, only_path: false, host: 'https://blog.7sheep.net' )} 1234 Post.all.map { |p| PostsHelper.post_path_with_date(p,   only_path: false,   host: 'https://blog.7sheep.net' )} Really neat,...

Two big advantages to storing data in your own region

We blogged already in the past about this topic here, here and here but how is the situation for the US market? Companies and organisations on the Business and Enterprise plans can choose to have all the servers that store their activities in the US or in the EU. 7Sheep not only focusses on the importance to host personal data for EU organisations in the EU but also to do the same for the US. This is important for two reasons: Speed When your 7Sheep account is physically located in your region it will be faster. Data does not need to travel around the world and the application feels snappier. I admit we talk about very short delays but they add up and many short delays can affect your user experience. Regulations In the US there is no single, comprehensive federal (national) law regulating the collection and location of storage of personal data. E.g. some states have rules regulating the transfer of personal data outside your jurisdiction for state agencies or state contractors (see Practical Law) However, it should be noted, especially for marketing that some parts of the US are tightly regulated: “The CAN-SPAM Act is a federal law that applies labelling and opt-out requirements to all commercial email messages. CAN-SPAM generally allows a company to send commercial emails to any recipient, provided the recipient has not opted out of receiving such emails from the sender, the email identifies the sender and the sender’s contact information, and the email contains instructions on how the recipient can easily and without cost opt out of future commercial emails from the...

The ‘least techie as possible’ guide to regional settings

After Mike’s blog about importing data, I got a couple of questions about changing regional settings for Excel files. So, I thought I’d talk you through it. Clearly if you have an iota more skill with a computer than I do, then you don’t need to read any further… for those of you on my level, I hope it helps! (A HUGE caveat before we start – you can import into 7Sheep with an Excel sheet using any regional setting, please don’t panic!) Why does it matter? Regional settings define more than just language. It also defines data formats – from dates to numbers. So what? So it can cause problems. About a year ago, whilst testing a new import function with 7Sheep we realised that we had a problem. Mario could import data, Mike could import the same file and me? I couldn’t. We made sure that I had the latest version of the browser (although that didn’t matter), we changed browsers and still had no luck. A bit of research later – we realised it was because I was using a UK regional setting for my computer and Mike and Mario were using Austrian. But why do I even need to think about this? Imagine how we interpret a table of data: The lines between each column or row tell us where one starts and another one ends. A line is a visual default list separator for a table which tells us how to read it. For importing and exporting data your computer programs needs these separators too, they just don’t use lines. And here’s the crux of the issue: Different regional...

A new threat to the safe harbour agreement

Reading this article on the ars technica site on July 14th worried us. The headline alone ‘Obama Administration says the world’s servers are ours’ raised our hackles. But, perhaps it is being overly scaremongering. Sadly, not so. It also serves to totally undermine the already fragile data safety net for Europeans that the Safe Harbor Agreement still has. It centres around a legal wrangle between Microsoft and the US Government, who are insisting that Microsoft must hand over e-mail stored in Dublin, Ireland. The case is revolving around accessing information with regard to another case involving Drug Trafficking but the implications are far wider. As noted in the article, the Irish Supreme Court have cited the Mutual Legal Assistance Treaty as the method which could be used by the US to access information stored on servers within the EU. The Bilateral treaty, which entered into force in 2010, places limitations on use to protect personal and other data (Article 9) but within the context of a criminal investigation the obligations of assistance are clear. It will be interesting to watch how this case unfolds. If it does not go in Microsoft’s favour the implications of US government reach into personal data stored within the EU will only further undermine, or indeed shoot stone dead, the current Safe Harbour Agreement which after the NSA scandal is only just clinging...

The ‘least techie as possible’ guide to regional settings

After Mike’s blog about importing data, I got a couple of questions about changing regional settings for Excel files. So, I thought I’d talk you through it. Clearly if you have an iota more skill with a computer than I do, then you don’t need to read any further… for those of you on my level, I hope it helps! (A HUGE caveat before we start – you can import into 7Sheep with an Excel sheet using any regional setting, please don’t panic!) Why does it matter? Regional settings define more than just language. It also defines data formats – from dates to numbers. So what? So it can cause problems. About a year ago, whilst testing a new import function with 7Sheep we realised that we had a problem. Mario could import data, Mike could import the same file and me? I couldn’t. We made sure that I had the latest version of the browser (although that didn’t matter), we changed browsers and still had no luck. A bit of research later – we realised it was because I was using a UK regional setting for my computer and Mike and Mario were using Austrian. But why do I even need to think about this? Imagine how we interpret a table of data: The lines between each column or row tell us where one starts and another one ends. A line is a visual default list separator for a table which tells us how to read it. For importing and exporting data your computer programs needs these separators too, they just don’t use lines. And here’s the crux of...

What is the Safe Harbor Agreement?

A little over a year ago we published on a company blog a post about the Safe Harbor Agreement. It explained what is was, why it mattered and how we adhere to it (the original post can be found below.) Data Security Obviously, with 7Sheep data security is extremely important. And we need to re-look at the Safe Harbour agreement as clearly something isn’t working. After the NSA scandal, there were fears that the EU would suspend the Safe Harbour Agreement. They didn’t, but the European Commission did issue a statement in January stating: “EU data subjects must have clarity and thus must be able to trust that if their data is transferred to the US, it is not routinely screened by the NSA. After all, the purpose of the Safe Harbour was to provide EU data subjects with a higher level of protection than available under the law in the US, in order to meet EU standards of data protection. Safe Harbour is meant to be an island of EU-style data protection within the US.” They have also passed on a list of 13 requirements for the Safe Harbour Agreement to work. Over the coming months it will be interesting to see where and how this goes – and also how it will relate to data privacy more generally in the EU. We get asked by clients a lot about the Safe Harbour Agreement. As we work with so many EU programmes/public entities/companies based in Europe we also find ourselves needing to make sure third party products and services we recommend are either based in the EU or have...