Upgrading Ruby on Windows with Chocolatey

I need to add an updated version of Ruby so I could use Ruby on Rails 6. I found an easy way to do this using Chocolatey. Chocolatey offers a free version for personal use.

I’ve used Railinstaller in the past to help, but it seemed that their stacks were a little outdated when I looked (and they didn’t have anything beyond Ruby 2.3).

That’s OK because using Chocolatey was super simple.

  1. Install Chocolatey
  2. You should now be able to run ‘choco install ruby’ or ‘choco upgrade ruby’ depending on what you want to do (Ruby chocolatey page)

Since I’m running URU, I just needed to add the bin path to it, and now I can switch between Ruby versions easily.

Advertisements

Using Lists in TinyMCE

I’m using TinyMCE in one of my Rails apps and I had trouble today pasting in text with bullets.  TinyMCE injects paragraphs <p> in the code, so the HTML ended up looking this.

ScreenHunter 212

That ended up with the text for the bullet point being on a different line (above) the text for that bullet point.

This probably isn’t the proper way to do it, but I ended up going to the second item in the list and clicking enter.  This created a new line that wasn’t preceded with the <p>.  After that I clicked enter and created new lines in the code for each of the bullet points.

On my toolbar I don’t have the option to add lists which made it more difficult.  In the future, I may try to add plugins to handle this to see if it makes it easier.

Password Protect Staging

I wanted to password protect my staging environment on Heroku.  Here’s a simple way to do it.

In your application controller, enter:

if Rails.application.secrets.auth
  http_basic_authenticate_with \
  name: Rails.application.secrets.auth_name,
  password: Rails.application.secrets.auth_pass
end
Then in your environment variables in Heroku (for your staging app), enter these variables:
AUTH = true
AUTH_NAME = <user name you want to use>
AUTH_PASS = <password you want to use>

Free Quick Start Tools When Building Websites

When I’m creating a site there’s certain things that I need to create each time.

Here’s a list of some of my favorite tools – each free:

Name Generator

Namelix – enter a term (or terms) and this AI powered tool gives you name suggestions.  I usually add additional search criteria to only suggest to names with available domains

Privacy Policy

Shopify Privacy Policy Generator – create a privacy policy for your site

 

Terms of Use

Shopify Terms and Conditions Generator – creates terms geared more towards sites that sell products or services

Termly – can create terms geared towards SaaS products (paid and free options)

 

Cookie Warning/GDPR

Cookie Consent by Insites – makes it easy to create a warning to all site visitors that you use cookies

Design

BEE Free – use their tool to create responsive email designs

 

Customize Form for Mailchimp

I bought a HTML template that had an email subscription form and I wanted to make it work with Mailchimp.  I wanted to keep the style of the template and not use a Mailchimp styled one.

It took some work, and I didn’t find documentation to do it, so here’s what I did:

(1) I went to my email list in Mailchimp and then Form Builder (Signup forms > Form Builder)

(2) Go to the URL provided for the form

(3) On the page that the URL takes you to (with the form), view the page source

(4) Copy these pieces of code from the source into your code:

(a) where your form should post to:

<form action="https://yoursite.us19.list-manage.com/subscribe/post" method="POST">  

    <input type="hidden" name="u" value="foo">
    <input type="hidden" name="id" value="bar">

(b) for each field that you want to capture, find the name of the field and paste it as the name into the matching fields on the form you’re updating:

<input type="email" autocapitalize="off" autocorrect="off" name="MERGE0" id="MERGE0" size="25" value="">

(c) form submission details:

<input type="hidden" name="ht" value="foobar"> <input type="hidden" name="mc_signupsource" value="hosted">

If you submit the form and it redirects you to the web form instead of subscribing you to the list, it probably means that you have a name attribute wrong on one of your fields (and when you submitted, Mailchimp didn’t know what to do with that field).

Using ActiveAdmin to Log In As User

When you’re supporting users with issues, it can be handy to log in as them to re-create what they’re experiencing.

ActiveAdmin makes this easy to do.

When you have the gem installed, and have a app/admin/users.rb file, you just need to add this code in there:

# creates a link to sign in as the user on view user page of admin
show do |user|
  attributes_table do
  #We want to keep the existing columns
  User.column_names.each do |column|
    row column
  end
  #This is where we add a new column
  row :login_as do
    link_to "#{user.username}", login_as_admin_user_path(user), :target => '_blank'
  end
end
end

controller do
  def find_resource
   scoped_collection.friendly.find(params[:id])
  end
end