Going back two pages in Ruby on Rails

Last Updated on November 30, 2019 by Christopher G Mendla

I had a situation where I had a list of records with edit buttons. After editing a record, the normal course of things is to show the document. The user wanted an easy way to get back to the list.

Tags: Read more
Read more

Rails – Pop up window with no header, footer or navigation

Last Updated on November 30, 2019 by Christopher G Mendla

I needed to have a window pop up in a Rails Project  without having the header, footer and navigation.

Tags: Read more
Read more

Accessing an external sql database from a rails app where the schema prefix differs from the schema prefix used for the app’s tables.

Last Updated on November 30, 2019 by Christopher G Mendla

This covers a situation where you need to have rails access an external sql database other than the database used for the application. For example, you might need to pull information from one table to populate fields in your current application.  This is further complicated if your application is using a schema prefix.

Tags: , Read more
Read more

Capturing failed logins when using adauth

Last Updated on November 30, 2019 by Christopher G Mendla

I use the adauth gem to provide authentication through Active Directory for Rails applications. I wanted to give the apps the ability to store failed logins. In other words, if someone tries to log onto an app and their login fails, the IP and login name used will be written to a file.

Tags: Read more
Read more

Use whoami to check before running bundle install so you don’t run it as root

Last Updated on November 30, 2019 by Christopher G Mendla

I screwed up my droplet (ruby on rails) on my digitalocean hosting by running bundle install as root. When you do that, there is a warning that this will break rails for other users. I haven’t taken the time to figure out how to fix that. Since I was getting started with that hosting, I decided to simply delete the existing droplet and recreate it.

Tags: , Read more
Read more

Viewing your SQLLite Data (Ruby on Rails beginners)

Last Updated on November 30, 2019 by Christopher G Mendla

When people are starting out with Ruby on Rails, one of the key elements is to be able to view the contents of the SQL file. For most people, they will use the SQLLite database. This is a limited implementation of SQL. The tables are all stored in one file which is located in /db of your Rails project.

Tags: , Read more
Read more

Tried to use Westhost’s preferred cpanel hosting for Rails — NO GO

Last Updated on November 30, 2019 by Christopher G Mendla

Before starting to use any hosting account for a Ruby on Rails project, check the versions they are offering.

Tags: , Read more
Read more

Vulnerability Scanner for Ruby/Rails

Last Updated on November 30, 2019 by Christopher G Mendla

I found a tool called brakeman that does vulnerability scans of rails applications. It installs as a gem and you run it from the command line. I had some issues with it using up memory but found a way around it.

Tags: , , Read more
Read more

Use Rake Notes instead of Git Grep to get a list of notes in your rails project

Last Updated on November 30, 2019 by Christopher G Mendla

When you create a Rails project, it is helpful to put notes in the project. The notes can look like the following in your controllers:

# TODO change the alignment of the column

    # FIXME – User password retrieval is not working as expected # OPTIMIZE Add indexes

Or, in the case of views, use the following format

Tags: Read more
Read more

A quick way to have a link_to show as a button instead of a text link

Last Updated on November 30, 2019 by Christopher G Mendla

link_to can be modified to show a button instead of a text link. The trick is to enclose the link/button text in a button tag and add .html_safe .

<%= link_to “My Blog“.html_safe, ‘http://blog.chrismendlatech.com’, target:’_blank’, class: ‘button’%>

<%= link_to "< button>My Blog< /button>".html_safe, 'http://blog.chrismendlatech.com', target:'_blank', class: 'button'%>
Tags: Read more
Read more