Accidental Technologist

Musings about Entrepreneurship, Technology and Software Development

  • Home
  • About
  • Still River Software
  • Privacy Policy

Powered by Genesis

How to Fix Rails Flash Rendering When Using Hotwire

May 14, 2021 by admin Leave a Comment

Tweet

I added Hotwire to a Ruby on Rails application I’ve been working on and discovered some issues when rendering flash messages. Yesterday I wrote about problems related to CORS error using OmniAuth.  Today’s is not as exciting but still as annoying.

Problem

I was in the process of testing some validation changes I implemented and realized errors were not being displayed. I went through the typical debug scenarios and found that errors were being returned but just not displayed.

The code consists of just trying to create a user:

def create
  @user = User.new(user_params)
  if @user.save
    redirect_to root_path, notice: “User created successfully“
  else
    render :new
  end
end

When creating a user, the new form rendered but errors were not displayed.

Solution

The reason the messages were not being displayed is because of Turbo and Rails UJS conflicting. Solving the problem can be done in one of two ways.

1. It appears Turbo expects form submissions to redirect to a new location. When there is an error, we are staying on the same page. Adding status: :unprocessable_entity to the render fixes the problem.

def create
  @user = User.new(user_params)
  if @user.save
    redirect_to root_path, notice: “User created successfully“
  else
    render :new, status: :unprocessable_entity 
  end
end

2. A similar solution from yesterday’s post also works. Adding

data: { turbo: false }

The form declaration disables turbo and lets Rails UJS handle as desired.

I hope future versions of Turbo handle this better.

Share this:

  • LinkedIn
  • Twitter
  • Facebook
  • Email
  • More
  • Pinterest
  • Tumblr
  • Pocket
  • Reddit

Filed Under: Hotwire, Ruby on Rails Tagged With: Hotwire, Ruby on Rails, Turbo

RailsConf 2021 and the Future of Conferences

April 20, 2021 by admin Leave a Comment

Tweet

Railsconf 2021 flag

I attended RailsConf this year, as I did last year. Due to COVID-19 these events were virtual-only. Unlike last year, this year’s event included a live component for keynote speakers as well as a large number of Discord rooms so that attendees could live the hallway track as best a virtual even could provide.

Organizers reported attendees took part from 61 countries.

CleanShot 2021 04 20 at 16 14

There were 5 keynotes, 60 talks (not including attendee lightening talks) and 11 workshops over 4 days. The talks were prerecorded so they could be viewed at anytime. This is a nice feature; as someone who has attended the in-person RailsConf in the past, it’s always hard to decide what talks to attend and sustain the energy to watch one during every time slot. 

The keynotes and workshops were live and took place in the afternoon and late morning, respectively. This year live lightning talks, game show, sponsor talks and speaker Q&A were added and made the experience feel as close to in-person as possible.

The 60 session talks will be up on the Ruby Central Youtube channel with a month after the event. Lots of really great talks and tons to learn.

This format worked great but I do miss the in-person events when you can see old friends face-to-face, have good conversations and enjoy group dinners out. I hope next year there is an in-person component of RailsConf. It does appear RubyConf will offer both in-person and virtual attendance. This gives attendees options and likely means more people can attend since some would miss because they couldn’t get away. 

I don’t know the numbers for previous RailsConf, but I would have to think attendance was not close to 61 countries.

We are seeing the future

As bad as COVID-19 was for so many, we may see some positive changes for the future.

Conferences were designed to be in-person, face-to-face meetups, bringing attendees from all over the world to a central location. COVID-19 has shown us there had to be a different way. 

Organizers had embrace a new way of holding events or shutdown. Technologies like Zoom and Mux proved online video is a solid technology, capable of the demands of many users.

Events than can offer both an in-person and virtual experience, stand to gain the most. This opens up opportunities for both organizers and attendees. People who would not be able to attend a particular conference in-person would now not miss the event because they can watch in the comfort of their home or office. Organizers that had to limit attendance can now open up and allow so many more to take in the event. Win..win.

I’m looking forward to attend more conferences in 2021 than ever before. I will attend some in-person but will attend others virtually. The RailsConf organizers and folks at Ruby Central should be applauded for a great job.

Share this:

  • LinkedIn
  • Twitter
  • Facebook
  • Email
  • More
  • Pinterest
  • Tumblr
  • Pocket
  • Reddit

Filed Under: Ruby on Rails Tagged With: railsconf, rubyconf

Recent Posts

  • How to Fix Rails Flash Rendering When Using Hotwire
  • Hotwire Fix for CORS Error when using Omniauth
  • Fix Installation of Ruby using rbenv on macOS Big Sur
  • RailsConf 2021 and the Future of Conferences
  • Fixing Out of Diskspace Errors on Amazon EC2

Categories

Services I Love

HatchBox - Easy Rails Deploys Fathom Analytics
Follow @rbazinet

Rob Bazinet
@rbazinet

  • This is so true and has been my personal take on people complaining they are busy - https://t.co/YW8NTQLXtl
    about 3 days ago
  • Wow…https://t.co/h94ia053sL
    about 4 days ago
  • My Bills lost today but more importantly so did the Dallas Cowboys. Nice seeing the ‘boys done for the season.
    about 5 days ago
  • It looks like the Apple Xcode command line tools is a bit bloated for it to take this long… https://t.co/U0HObTvzXf
    about 2 months ago
  • How many people are mad that @elonmusk bought Twitter yet own or plan to own a Tesla? I bet many.
    about 2 months ago
  • RSS - Posts
  • RSS - Comments