I am Pedantic.

  • Archive
  • RSS
  • Talk to me

Fully Customizing Devise Routes

Devise is a full-featured authentication and account management framework for Ruby on Rails. It has many options, but the default configuration is definitely encouraged.

There are some basic URL (path) options that allow you to modify the basics of the routes that Devise supplies for all of its features, but they are very minimal.

devise_for :users, path_names: {
  sign_in: 'login',
  sign_out: 'logout',
  password: 'reset'
}

This means that Devise will use /login and /logout, but when it comes to doing password resets, confirmations, registrations, etc., it’s going to tack on the default Rails CRUD actions /reset/new, /reset/edit, /confirmations/new etc.

I can’t abide by those ugly URLs and want full customization ability for every single route. A brief aside: I’m using the model Person in my latest app instead of the ubiquitous User. I find the former to be more humanizing.

Given that, in order to customize every single route across the sessions, passwords, confirmations and registrations controllers for Devise, I used the following:

# Authentication
  devise_for :people, skip: [:sessions, :passwords, :confirmations, :registrations]
  as :person do
    # session handling
    get     '/login'  => 'devise/sessions#new',     as: 'new_person_session'
    post    '/login'  => 'devise/sessions#create',  as: 'person_session'
    delete  '/logout' => 'devise/sessions#destroy', as: 'destroy_person_session'

    # joining
    get   '/join' => 'devise/registrations#new',    as: 'new_person_registration'
    post  '/join' => 'devise/registrations#create', as: 'person_registration'

    scope '/account' do
      # password reset
      get   '/reset-password'        => 'devise/passwords#new',    as: 'new_person_password'
      put   '/reset-password'        => 'devise/passwords#update', as: 'person_password'
      post  '/reset-password'        => 'devise/passwords#create'
      get   '/reset-password/change' => 'devise/passwords#edit',   as: 'edit_person_password'

      # confirmation
      get   '/confirm'        => 'devise/confirmations#show',   as: 'person_confirmation'
      post  '/confirm'        => 'devise/confirmations#create'
      get   '/confirm/resend' => 'devise/confirmations#new',    as: 'new_person_confirmation'

      # settings & cancellation
      get '/cancel'   => 'devise/registrations#cancel', as: 'cancel_person_registration'
      get '/settings' => 'devise/registrations#edit',   as: 'edit_person_registration'
      put '/settings' => 'devise/registrations#update'

      # account deletion
      delete '' => 'devise/registrations#destroy'
    end
  end

The trick is to make sure your as named route aliases line up correctly with what Devise expects, and to ensure that you call devise_for before devise_scope (or its alias, as, like I did). You need to tell devise_for to skip the auto-creation of all of the routes for all of the controllers you’re using, then go ahead and define all of them yourself.

  • 4 months ago
  • 1
  • Permalink
  • Share

Why I Moved to Austin

To create things of quality, you must live a life of quality. Unhappiness or lack of passion in one area will bleed through to others.

— Brad Fults (@h3h) August 9, 2010
  • 8 months ago
  • Permalink
  • Share

Great Cities

Brian Bailey has me thinking so much about great things that I can’t help but share my responses to his latest in a series of stellar Uncommon newsletters.

What defines a great city?

More than anything I think the answer to this question is energy. There are many types of energy, but my favorite cities have a sense of positive energy and experimentation to them. I love Austin so much because it’s not run like clockwork—you can expect a parade, marathon, art show or food truck fair to interrupt the steady state of the city. These interruptions create wonderful opportunities for learning and experimentation with something outside of one’s comfort zone; they perpetuate a culture of action, change and flourish.

There are many other attributes that help define a great city, like the general attitude of the people, the weather and the cleanliness, but few are as singularly defining than the city’s cultural energy. Robert Pirsig tried to explain this same character through his elemental concept of “quality” in Lila, a remarkable dive into the very source of our social morals (and highly recommended sequel to his more famous Zen and the Art of Motorcycle Maintenance).

What is one of your favorite cities?

Besides the obvious, I’ll say Vancouver, British Columbia. There’s a delightful interplay of humility, energy and beauty in Vancouver. I have never before or since felt the way I did after attending a fireworks show on the beach for Canada Day, while walking back to my hotel amidst tens of thousands of city residents who had taken over the streets. Cars were nowhere to be found and we effortlessly filled the streets, building to building with smiling faces and warm embraces, the city strong and welcoming all around us. Truly moving.

  • 9 months ago
  • 2
  • Permalink
  • Share

Seeking Fiercely Competent People

Within the past few years I realized that I’m involved in a constant search for fiercely competent people.

For a long time as an adolescent and young adult I felt compelled to seek more information, better ideas and novel facts. In school I rarely felt kindred with any of my friends or classmates, though. There were certainly people much more intelligent than myself, but they always seemed to have different aims and different passions. It took me many years to understand in more depth the type of person and type of thought which I was seeking.

I admire and feel most kindred with those people who are fiercely competent at a craft—sometimes physical, sometimes digital or intellectual. They have worked arduously to hone their skills and accept nothing less than excellence as their products. Their state of mind is one of deep resonance with their mission of quality and comprehensiveness. They produce excellent things as an internal imperative: it could not be any other way.

Talking with and learning from these people is usually a deeply rewarding experience. I feel that I can learn and grow more in a hour with such a person than ten with a mere “expert” or “professional” in a given discipline. It’s delightful and humbling to find such a person who is willing to share their work and their passion.

I anxiously embrace any chance to have those experiences and treasure them greatly.

  • 9 months ago
  • Permalink
  • Share

Passion, Business & Life

The insane-hours startup life mantra is such bullshit and so annoying. It’s ridiculous that so many people get away with representing it as the only way to go if you’re conducting “actual” business or devoting yourself to your “real” passion.

We have to combat this mentality by building vibrant businesses without insane hours or unreasonable demands on people. We work to live and pursue our passions while building meaningful family and social lives.

Incredibly few and tragically unbalanced are those who reflect on a life of toil and wish they could have neglected loved ones more to achieve some far off dream. The best version of success is the one that has been realized as part of building a human life with other humans. Our passions should guide our pursuits, not dominate our humanity.

  • 10 months ago
  • 2
  • Permalink
  • Share
Beliefs and actions are like two separate musical tones, each with its own pitch, each repeating at a certain wavelength. Integrity is when the two come together, when beliefs and actions are in total alignment. A certain cosmic vibration occurs — there is resonance.
Jack Cheng, Integrity
  • 10 months ago
  • 1
  • Permalink
  • Share

Project Names in Poor Taste

There’s a trend within open-source software development of naming projects after sexual innuendo and other puerile topics, to elicit a laugh or an eye roll from its potential users—other developers—I’m sure. I’m thinking of names like:

  • Texticle
  • libupskirt
  • Cocaine

It’s sad that these authors would jeopardize the utility of their libraries by giving them puerile or offensive names. All things considered, everyone would benefit more from better naming of projects with these types of names and I don’t think any real value would be lost.

Let’s be more mature when naming things.

  • 11 months ago
  • Permalink
  • Share
Instead of creating institutions that span the generations, we insist the young make everything over anew. We keep ourselves confined to our peer group well into adult life even in political circles; it’s as though we never truly leave public school with its strict categorizations by birth year.
Astra Taylor, “Unschooled”, n+1 magazine, Winter 2012
  • 11 months ago
  • Permalink
  • Share
When those who question the validity of a relatively new scientific theory are accused of mythical crimes by its supporters, and conversely skeptics attack believers for trying to impose a dictatorship, something other than science is at stake.
Christopher Clausen, “Left, Right, and Science”, Wilson Quarterly, Spring 2012
  • 12 months ago
  • 1
  • Permalink
  • Share
Hiring well is the most important thing in the universe. Nothing else comes close. It’s more important than breathing. So when you’re working on hiring—participating in an interview loop or innovating in the general area of recruiting—everything else you could be doing is stupid and should be ignored!
The Valve Employee Handbook
  • 1 year ago
  • 1
  • Permalink
  • Share
← Newer • Older →
Page 1 of 20

Pedantry, software, freedom, beauty and minimalism.

by Brad Fults

Brad on the Internet

  • h3h on Dribbble
  • @h3h on Twitter
  • Facebook Profile
  • h3h on Flickr
  • h3h on Last.fm
  • h3h on Gowalla
  • h3h on github
  • RSS
  • Random
  • Archive
  • Talk to me
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr