Image for post
Image for post

Active storage is a layer inside of rails that helps you connect with cloud services like AWS. Its also connects to other providers like Azure and Google cloud. You can use it to run tasks as well, but in this guide, I will focus on uploading a file to s3 and displaying it inside your rails app.

Note: Have you thought about the environmental impact of the servers you use? Check out this link to look at the environmental impact of the cloud servers you use.

In order to use Active Storage, you will need to set up a database. ActiveStorage should be installed with rails. You can use the rake task bin/rails active_storage:install to generate some migrations that you can run on your database. Run these with bin/rails db:migrate. This will create two tables, active_storage_blobs and active_storage_attachments where the file information and attachments are stored. …


One thing that has recently puzzled me with my discoveries of the Yii PHP framework is to do with how authentication rules work. (In particular RBAC)

I have been recently working on a big project for work that is quite complex with quite a few different systems that are all connected to each other. It also supports different devices, like the iPad and the iPhone. For this app it is important to restrict a user to a particular set of assets (that they create) and share these with other users in their company. To implement this, I stared by looking into the standard approach recommended by Yii documentation and that is the Authorization Component. …


I have recently stumbled on some really awesome tools, Code Igniter and Netbeans IDE for PHP development. I’ve used eclipse for Java development through uni and found it really great. After finishing that I found that using eclipse for PHP just was too slow and didn’t have the right tools for the job.

I used dreamweaver for a while but then stumbled on Netbeans and I am really amazed at how it works and so well. …


Vancouver is an amazing city. So alive and vibrant. It has an arty feel to it. Its bigger than Adelaide but the main shopping areas felt emptier and less alive compared to say Rundle Mall in Adelaide.

I spent most of my time in Granville St in the Samesun backpackers hostel. It was a great stopover point until my journey up to Whistler. Lots of international visitors and people in similar situations, trying to find themselves in this amazing city.

At night time, the street came alive, with party goers heading to clubs and homeless people in search of donations in return for their various antics, be it card tricks or music made with spoons. Granville St near the backpackers is a dirty street but that gives it that character. …


I am currently really enjoying working at Bigwig wired in Adelaide doing web development for them. I really enjoy working with a team of designers and then turning the designs into reality and integrating them into CMS’ for clients.

I have very quickly accelerated my knowledge of css, and JavaScript (mainly jQuery) in a small time as there is a big variety in the types of clients and websites that we work on, its definitely a skill to use the latest development techniques but to also keep in mind how it will look in the older browsers like IE7 (we don’t worry about IE6 unless a client specifically requests it). jQuery is definitely an awesome tool for writing JavaScript really quickly and cross browser. …


I am currently working on a website that requires some scrollable elements on it. The design specification is to do away with the scroll bars to allow for a better more simplistic design. Now I remember this being done in the past in flash, but I wasn’t going to be using flash. So naturally I went out to find a jQuery solution. In most cases doing a google search or stackoverflow search finds some code that needs some tweaking and then away we go, but this time I couldn’t find anything! …


Recently while working on a particular project we had some strange errors that came up. In the usual php like way, the error messages where not very helpful and didn’t allude to what the actual problem was. Have you seen an error like this before?

**Headers Already Sent on line 392

**

Invalid argument supplied for foreach()

Well, this handy functionality that I discovered in php made my life easier.

var_dump(debug_backtrace()); die;

I placed this right before the code that was complaining, and it allowed me to see where this function was being called from. I was then quickly able to fix the problem and be on my merry way.

Originally published at kieranandrews.com.au.


I recently attended startup weekend in Adelaide. I was really excited because it would be a good opportunity to build something and test my new skills I had learn recently programming ruby (and using rails).

The weekend started on Friday night where attendees had the chance to pitch their ideas in a quick 1 minute pitch. There where some exciting ones. The ones that stood out for me was a pitch about a rating system for health care professionals , a iPhone app to find and rate pubic toilets and a coffee rating app.

I decided to join the team doing rating and listing of health care as I though this would be really useful for lot of people if it was successful and seemed like something I could help and build a great MVP. …


I had a bright idea for an improvement for the app I am currently working on. I have a Rails model that has only 2 rows in the database and the data is never changed, it has quite a lot of relationships and is used quite extensively. My idea was to remove the database out of the equasion and create a Model that would be entirely self dependent. Here I will show you my methods of maddness:

def MyModel include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming def self.attr_accessor(*vars) @attributes ||= [] @attributes.concat( vars ) super end def self.attributes @attributes end def initialize(attributes={}) attributes && attributes.each do |name, value| send("#{name}=", value) if respond_to? name.to_sym end end def persisted? false end def self.inspect "#<#{ self.to_s} #{ self.attributes.collect{ |e| ":#{ e }" }.join(', ') }>" end end

Originally published at kieranandrews.com.au.


I recently made a talk for Map Reduce with a focus on Ruby.

You can see the slideshow here

http://slid.es/kieranandrews/map-reduce-in-ruby

I presented the slide at Adelaide.rb Meetup and at work.

Originally published at kieranandrews.com.au.

About

Kieran Andrews

I enjoy building software, making web applications, surfing, snowboarding and cooking!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store