Jay Killeen


4,380 Experience
27 Lessons Completed
0 Questions Solved


Posted in Using Vagrant for Rails Development Discussion

I am getting the error "ERROR: You must specify at least one cookbook repo path". Will come back if I figure it out. The only changes I have made to Chris' code is making it Postgres instead of MySQL.

Posted in Who is using Hashicorp Otto?

Cheers James.

I've never used AWS, mainly just digital ocean or Heroku (depending on how much cash I have to spent on a project). So right now I can't even deploy as the credentials screen is a bit ambiguous.

It is asking me to provide a path to my public key file which defaults to .ssh/id_pub.rsa. As I am on a WIndows Machine I guess my VM machine isn't picking up my key or isn't able to correctly pass it over to Otto.

I see there is a pull request though for a digital ocean infra but it is being delayed until a convention is agreed for other infra providers.

Mitchell mentioned on The Changelog episode though the 0.1.3 would be a major dev ready release though so waiting eagerly for that to come.

Are you using AWS for your infra or just pushing to Github and have a CI pick it up?

Posted in Who is using Hashicorp Otto?

I have a question up on StackOverflow as well if anyone is interested in commenting.


The idea I have is that, because I am on a Windows machine, I am limited to using Rails Installer to build an app on Windows. But what if I want to be on a Window machine, spin up a dev environment using Otto with the bare minimum requirements and then rails new from inside that dev environment.

This would then allow me to bypass any potential issues being on Windows.

Posted in Who is using Hashicorp Otto?

Hi All,

I've recently gotten back into my rails development after some Salesforce related projects at my work. In that time I had to format my laptop from Ubuntu to Windows 10.

I've been struggling on my Windows 10 machine because it just isn't as easy as installing gems to a UNIX machine and building a rails app (like everyone else is doing on MAC).

I started to learn Vagrant so I could run things up in a VirtualBox instead running Ubuntu. This was great but I also wanted to get off of Heroku because I just can't afford to spend money on convenience.

Enter Hashicorp Otto. I've been playing around with this for the last week or so and it is looking like a real tool belt replacement.

Is anyone else using it out there? What have you found so far? I have run into a few struggles installing Postgresql correctly on an existing app and also had to delete some of my old Vagrantfiles because they seemed to be getting in the way (ie Otto installing Ruby 1.9.8 or something instead of 2.2 which was specified in my Gemfile).

Anyway thought I would get some of the conversations flowing and also suggest a video on how to get Otto up and running and maybe an example of how easy it is to go from new app, to dev machine building and then deploying to something cheap like Digital Ocean.

Posted in Using Vagrant for Rails Development Discussion

It is weird. When I ssh inti vagrant and run pwd I see `/home/vagrant` but when I run ls I don't see any files.If I run `ls /vagrant' I see all my files though that are being synced.

This boggled my mind for at least 4 or 5 hours.

If I `cd /vagrant` and `ls` I'll see all my files. But if I run `pwd` from there I am in `/vagrant`.

Is anyone else confused why vagrant would create a folder in my home folder `/home/vagrant` but actually sync with `/home`??

So happy now that I have figured this out!!! :D

Posted in Ideas for building a Wiki in my app

Oh and the comment bases stuff was pretty much straight from the polymorphic comments video that Chris did and the markdown is from the markdown video :smiley:

Posted in Ideas for building a Wiki in my app

The gist can be found at https://gist.github.com/jaykilleen/b09eb78b85e083368cb5.

I pretty much dumped most of my code relating to the wiki pages here except for the logic around users etc and a few other things. If you have any ideas to improve the code please let me know. I can do with a lot of drying up but it works. I'm lacking in time due to some other features I need to get out so if I improve it I'll update the gist.

Hope it helps someone to get some inspiration. I pretty much went from the irwi gem as the starting point with the migration and then free styled it from that point.

Posted in Ideas for building a Wiki in my app

Ill do a gist

Posted in Ideas for building a Wiki in my app

So happy!! Just shipped my wiki feature which included the ability for me to create pages, edit them as super admin, includes markup, a sidebar panel for quick navigation and I even hooked up Wistia so that I could embed some training videos I had into my wiki!

Also used the existing comments feature from your comments video and made it so users can comment on each wiki post! So freakin' awesome!!

Did I mention I wrapped some Rspec round all this. Still not doing full TDD but happy that it is not breaking without me knowing :smiley:

Posted in Ideas for building a Wiki in my app

Oh damn that is exactly what I need! I have a polymorphic comments feature that doesn't do the line breaks and things. Thanks Team Gorails!

If I keep learning at the rate I am going then I might have a crack at one of those gems. I have a few use cases for a really easy to build wiki app. I'll let you know how I get on.

Posted in Ideas for building a Wiki in my app

Oh and Chris, how did you get it so users can comment using Markdown? That would be a cool video.

Posted in Ideas for building a Wiki in my app

My users are all internal customers of our business. They are pretty information poor when it comes to our systems and processes and our company intranet is not very feature rich. So I'd like to build a wiki style feature inside my app so if they get to something they don't know about they can click help links etc and read about certain business logic etc.

I have seen https://github.com/alno/irwi which doesn't support Rails 4 and also https://github.com/nirnanaaa/gollum_rails which is no longer being supported so it doesn't seem like there is a Rails plugin style Gem to extend the functionality of your existing Rails app.

Anyone have any other ideas on where a good Gem might be?

Otherwise I am going to lookinto irwi a little more and just extract those features into my app. Maybe even one day fork it or build my first open source gem for rails that gives this functionality to your Rails app :) Probably won't happen though haha. Can only dream.

Worse comes to worse I'll just build a static page in the app and manually link it all together.

Posted in Non Restful actions in the controller

Okie dokie, so I thought long and hard about this one and have come up with a pattern that suits me. I have separated out the idea into two features 'custom views' and 'dashboards'. Dashboards are more complex and I will just run these with their own controller, routes and models. 'Custom Views' is for more specific model related views that I want the users to have quick access to. So what I have done is:

I'll make the example on my customers model.

  1. Created a new route that gets hit before the customer resources (so it doesn't conflict with the customer show route).
  resources :customer_custom_views, :controller => "customers/custom_views", only: [:index, :show]
  resources :customers, only: [:index, :show, :search] do
    collection do
      match 'search' => 'customers#index', via: [:get], as: :search
  1. Created a controller nested inside a folder called customers -controllers --customers ---customer_views_controller.rb
class Customers::CustomViewsController < ApplicationController

  before_action :authenticate_user!
  before_action :redirect_blocked_user

  def index
    @customer_custom_views = built_custom_views

  def show
    @id = params[:id]
    case @id
      when 'owned'
        @customers = policy_scope(current_user.customers).paginate(:page => params[:page])
      when 'active'
        @customers = policy_scope(Customer.active).paginate(:page => params[:page])
      when 'active_blocked'
        @customers = policy_scope(Customer.active_blocked).paginate(:page => params[:page])


    def built_custom_views
      built_custom_views = ['owned', 'active', 'active_blocked']

    def direct_to_built_custom_view
      if built_custom_views.include?(@id)
        render "show_#{@id}"
        flash[:error] = 'That is not a valid custom view for customers'
        redirect_to customer_custom_views_path
  1. Created the views in a nested folder inside the customer views

  2. Added the links to the navbar with

<ul class="dropdown-menu" role="menu">
  <li><a href="<%= customer_custom_views_path %>">Views</a></li>
  <% if current_user.active_customers.present? %>
    <li><a href="<%= customer_custom_view_path('active') %>">My Active Customers</a></li>
  <% end %>
  <li><a href="<%= customers_path %>">Customers</a></li>
  <li><a href="<%= customer_types_path %>">Customer Types</a></li>
  <li><a href="<%= customer_areas_path %>">Customer Areas</a></li>
  1. Created a simple index.html.erb that lists all the different custom view I have templates for (this is hardcoded at the moment so I will figure out how to create an activerecord style hash in the controller that includes the name, descriptions etc.
  <p>Please select from the list below to be directed to a range of different views that relate to customers.</p>
  <div class="table-responsive">
    <table class="table table-hover">
          <td><%= link_to 'My Assigned Customers', customer_custom_view_path('owned') %></td>
          <td>View all the customers assigned to you.</td>
          <td><%= link_to 'Active Customers', customer_custom_view_path('active') %></td>
          <td>View all the customers assigned to you or your direct reports that are flagged as active.</td>
          <td><%= link_to 'Active Blocked Customers', customer_custom_view_path('active_blocked') %></td>
          <td>View all the customers assigned to you or your direct reports that are active but blocked from purchasing.</td>
  1. And show pages for each of those reports such as
<% content_for :title, "My Active Customers" %>

<h2>My Active Customers</h2>

<p>Below are all the customers that are assigned to you or one of your direct reports. It has been filtered for active customers which means the 'flag' field on the project has been marked as 'active'. Not all your customers are active so if you want to see all the customers assigned to you then you should go to <%= link_to "Customers", customers_path %> and search there.</p>

  <strong>Customer Count</strong>
  <%= @customers.count %>

<%= render 'shared/pagination', :collection => @customers %>
<%= render "/customers/table" %>
<%= render 'shared/pagination', :collection => @customers %>

I can probably do more to dry this up or make it more dynamic but for now it allows my users to have a page they can go to that relates to that particular table and quickly see bits of information that they want to see. It was the really easy to extend this pattern to other tables like 'projects' or 'prices' etc.


If anyone has any ideas on how to improve this please shoot me your ideas. As you can see most of this stuff is just getting a scope of the activerecord collection from the customer.rb.

  scope :active, -> { where(active: true) }
  scope :active_blocked, -> { where(active: true, status: 'Blocked') }
  scope :inactive_blocked, -> { where(active: false, status: 'Blocked') }

The Dashboards would have way more complexity like Top 10 Customers by Net Revenue would need to sum on the sales association then order, then limit, then include other tables etc etc so I will probably create a whole class/model that does all that and has its own controller and routes etc.

Posted in Refactoring with the Null Object Pattern Discussion

This is really cool. I am in a situation where I have many user roles and would love to be able to serve a navbar for each role. Yay! Thanks. Also in my views I have used the decorator pattern like `user_decorator.rb` and then made methods with a method `link_to_project` and then in that method done something like `object.project.present? ? h.link_to(object.project.name, project_path(object.project)) : ""` or, similar to your example in the video.

`comment_decorator.rb` with a method called `link_to_user` with `object.user.present? ? h.link_to(object.user.name, user_path(object.user)) : "Anonymous"`

I have done this everywhere so I might take the null object pattern to deal with the nav first then once I get familiar try and tackle all my decorator stuff.

Posted in Non Restful actions in the controller

Been looking around and it seems I may be able to do this on the index action instead of the show. Is there a way I can pass a value into the params on the index action?? So I could pass dashboard to the index action and then render a different view than the index.html.erb??


Posted in Non Restful actions in the controller

I tried this

  def show
    if params[:id] == "dashboard"
      @projects = policy_scope(Project)
      render :dashboard
    authorize @project

But ran into issues with my Pundit authorization before_filters (what I'd like to put is what I have written below but obviously you can't do that).

  after_filter :verify_authorized,  except: [:index, :show(params[:id] == dashboard)]
  after_filter :verify_policy_scoped, only: :index

I mean, I could do all this by making a whole new controller, route and just using the existing models and authorization but it just seems like such a simple thing to do.

Posted in Non Restful actions in the controller

I originally asked this question about building a reporting feature in my app https://gorails.com/forum/advice-on-building-a-reports-feature.

I'd like to simplify this question even further. I want to create custom views that my user can go to for certain models in my database. For example, I have a model called 'Project' and project has a veiw for index and show. So I can show a list of all the projects in the system, scoped using Pundit so the user only sees those projects they have the authority to see. The user can then click the project and go to its 'show' page. I then add a tab in my navbar called Projects which takes them to their index.

Now Projects can be assigned to individual users and a user can edit that project and mark it is 'active'. Meaning, 'I am assigned this project but I have a lot of projects so I want to mark this one as active because I am working on it'. Now the user goes away, navigates around my app, then wants to quickly click a link that takes them to their active projects.

Do I do this on the 'index' page? Do I create a new action on the controller called 'active projects' that renders to a view called 'active projects'? Can I place a scope on the model called active and then somehow make it so the index passed active as the parameter on the index? Essentially I could have heaps of these different scopes, active projects, inactive projects? I have a ransack search box that allows the user to do heaps of searches but it is difficult to use.

How would you guys implement this simple feature?

Posted in Import CSV data using RubyZip and Postgresql COP

two issues solved with this piece of code. It skips line one which is the header and appends the "\n" new line to the string.

          data.lines.map(&:chomp).each_with_index do |line, index|
            if index > 0
              line << "\n"
              raw.put_copy_data line
              counter += 1

Posted in Import CSV data using RubyZip and Postgresql COP

This is what the data looks like in when I am importing from csv when the command raw.put_copy_data line is run

"415906,\"BISHOP, JOEL\",9 GARCIA COURT,PEREGIAN BEACH,4573,QLD,EXTERNAL,D,230,Country,Blocked,JOEL,N,A17,407,004,464,H01,400659,001,C16,2014-08-28 00:00:00,neym,2014-03-04 00:00:00,llavejoy,4\n"

This is the same line when running from zip.

"415906,\"BISHOP, JOEL\",9 GARCIA COURT,PEREGIAN BEACH,4573,QLD,EXTERNAL,D,230,Country,Blocked,JOEL,N,A17,407,004,464,H01,400659,001,C16,2014-08-28 00:00:00,neym,2014-03-04 00:00:00,llavejoy,4"

Writing this comment helped me solve the issue!!

Posted in Populate dropdowns based on selection

Cool thanks Chris. That makes sense. Is this something that I should implement a JSON serializer for like resource json api? At the moment my app has no JSON api interface but from all the podcast listening I have been doing it should be something is should implement.