7 Reasons Why You Should Treat Your Custom Application Like an Employee

0

This is a cross-post from PanopticDev.com

Custom software can be an expensive investment, but if you design it to do a job and invest in it like an employee, you’ll be able to track results better and budget for it accordingly. So when a potential client comes to us looking to have a custom application built, one of the first things we want to know is, what’s its job? Whether it’s going to be a mobile app, a website, an API, an embedded system, a device driver, or whatever, every custom application ultimately works for that client, just like their employees.

Continue to full article

Setting up a Rails 5 app from edge

5

Update: Many people reported issues with installing the proper version of Rack, so I’ve updated step 3 to account for that.

I just returned from RailsConf 2015 and wanted to checkout some of the new features of Rails 5 that @dhh highlighted in his keynote. Here’s how I got up and running on edge rails in a few quick steps.

1. Create the project directory

2. Setup your environment

Rails 5 requires Ruby >= 2.2.2. I’m using RVM in this case, but you can use whatever Ruby environment manager that works for you.

3. Install edge Rails so we can generate a new project

Note that we included both Arel and Rack from source as well. At the time of writing, ActiveRecord requires Arel >= 7.0.0.alpha which isn’t available on RubyGems.org yet, and ActionPack requires Rack >= 2.0 which also isn’t released yet, so these two lines are required to resolve that dependency.

4. Generate the rails app

The --force flag will allow Rails to overwrite our Gemfile, and the --dev flag tells Rails to point to the edge version of Rails that we just bundled.

5. Profit!

 

Bash shortcuts to run Rails commands through Spring, Bundler, or ye olde scripts

0

Just about a year ago to date I posted some useful Bash shortcuts for Ruby on Rails commands. These are mix of aliases and functions that detect what version of Rails is present and routes commands which ever way that version expects, i.e. ./script/console versus rails console. Now that Rails 4.1 ships with Spring by default, there is yet one more way commands could be routed – through the spring binstubs. I’ve recently updated my shortcuts to account for this. Now my commands will use the binstubs if they are present, or fallback to the other version-dependent methods.

H/T to makandracards for helping me figure this out.

Cache busting AJAX requests and redirects

0

AJAX get and head requests are cached by default. This can cause problems when AJAX requests use the same URLs as a user would use during normal site navigation. jQuery can disable caching on a global or per-request basis. When doing so, jQuery adds a _={timestamp} parameter to the query string which should make each request unique. However, there are cases where an AJAX request results in a redirect which jQuery will happily follow. When that happens the _={timestamp} isn’t automatically appended to the new request, so the final response can still end up being cached by the browser even when you’ve told jQuery not to cache it. You can get around this in 2 ways:

  1. Make sure all redirects persist the _={timestamp} parameter, if present
  2. Add the proper header response parameters to prevent the browser from caching the request.

Here’s an easy way to implement the 2nd solution in Rails:

Dynamic enum fields in nested association forms in Rails Admin

4

We’ve had a few projects at Panoptic Development recently that made use of the RailsAdmin gem. Out of the box, RA satisfied about 95% of what we needed to do to complete each project, but there were a few edge requirements that we either had to make do without or find workarounds for. Don’t get me wrong, RA is a wonderful utility for quickly spinning up an administrative area for your Rails app. It’s loaded with really slick bells-and-whistles, and it has an incredibly flexible DSL for configuration. However, there are a few things it just doesn’t seem to be able to handle as-is and for which I’ve searched high and low for solutions for the last 9 months. I’m happy to report that I finally cracked one of these problems, and it wasn’t even all that complicated in the end.

(more…)

Go to Top