Jay Killeen

Joined

4,030 Experience
25 Lessons Completed
0 Questions Solved

Activity

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

Should there have been a step in this tutorial to install Rails on the server? Say around the area where Bundler is installed? Or did you pick an image that had Rails included?

Posted in Pretty urls with FriendlyID Discussion

A great introduction to friendly ids! Worked perfectly even on Rails5.0.0beta3

I really appreciate being able to watch the process you go through. The hardest part I have found in learning rails is incorporating TDD/BDD and I was happy to see you step through that with each of your features.

Very jealous by the way that you have all this time to learn it all as part of your studies. I'm self taught so have to fit everything in between my day job and social life. CS students must have very high pass rates to be able to work on such rewarding projects :)

Sorry for the questions, not really helping with your problem but just curious about the journey you've been on.

Ken what were you doing before you started learning Rails? This site packs some massive features. You must be dedicating a lot of time to learn so much so quickly :)

I was writing some code last night and saw your post just before I was about to go to bed. Ended up watching your videos for another hour hah.

Posted in Using Vagrant for Rails Development Discussion

I hadn't run the line `vagrant plugin install vagrant-librarian-chef-nochef`. I have done that although now Chef installation takes so long I stopped it. 1hr + so I don't think that classifies for 'This can take a while.`

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.

http://stackoverflow.com/questions/34171242/correct-way-to-create-a-new-rails-app-using-hashicorp-otto

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
    end
  end
  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
  end

  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])
    end
    direct_to_built_custom_view
  end

  private

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

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

    -views
    --customers
    ---custom_views
    ----index.html.erb
    ----show_active.html_erb
    ----show_active_blocked.html.erb
    ----show_owned.html.erb
    
  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>
</ul>
  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">
      <tr>
        <th>Name</th>
        <th>Description</th>
        <tr>
          <td><%= link_to 'My Assigned Customers', customer_custom_view_path('owned') %></td>
          <td>View all the customers assigned to you.</td>
        </tr>
        <tr>
          <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>
        </tr>
        <tr>
          <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>
        </tr>
    </table>
  </div>
  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>

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

<%= 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.

Yay!

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??

http://stackoverflow.com/a/9779820/2585189

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.