10 posts about
rubyonrails

Dev Tips: Escaping Special Characters

just happened that there are several issues / discussion topics around escaping characters these few days, so wanna share and remind every junior developer about these. 1) escaping in SQL statement BAD: execute('SELECT * FROM "users" WHERE "id" = ' + userId) there are occasions that you combine user provided data into a SQL that query database records. in the examples...


Read More

Issue during gem install pg with postgresapp on MacOSX

Issue during gem install pg with postgresapp on MacOSX thumbnail

Problem after you download postgresapp (http://postgresapp.com/), when you bundle install Rails app with pg gem, it will throw error saying cannot find pg_config Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/eddielau/.rvm/gems/ruby-2.5.1/gems/pg-0.21.0/ext /Users/eddielau/.rvm/rubies/ruby-2.5.1/bin/...


Read More

Learn backend development - Ruby on Rails

Here are some references to get you started with backend development with Ruby on Rails (http://rubyonrails.org/). Ruby Basics Online courses: https://www.codeschool.com/learn/ruby https://www.codecademy.com/learn/learn-ruby Familiar with Ruby's community (one strong reason people use RoR) http://rubyonrails.org/community/ Advanced: Other Ruby tools / libraries https://github.com/markets/awesome-ruby...


Read More

First two weeks working in F5 Works

First two weeks working in F5 Works thumbnail

How it started When I finished my high diploma, I started to find a programming job. At that time, I saw the recruitment post of F5 Works on the internet and sent the CV for it. Finally, I got this job and now working here. It is lucky that I got a job so fast. Time runs so...


Read More

differences of "be", "eq", "eql" and "equal" in RSpec

differences of "be", "eq", "eql" and "equal"  in RSpec thumbnail

In RSpec, when you first start writing test cases to compare expected results, it might be very confusing to pick from "be", "eq", "eql" or "equal". However, once you know the underlying differences of these methods, everything will be clear afterward. Let me go through them here with some examples. Compare Statements There are 2 groups of compare...


Read More

Gotcha using paranoia - a soft delete gem for Ruby on Rails application

Gotcha using paranoia - a soft delete gem for Ruby on Rails application thumbnail

To implement soft delete mechanism in Ruby on Rails, paranoia is the life-saver. Sample Usage After destroying a record, the record is still stored in the database, but it won't be returned in most of the ActiveRecord collection methods. For example, the following method call only returns Product that has not be soft-deleted: Product.all There are use...


Read More

5 months at F5 as an intern

5 months at F5 as an intern thumbnail

I had decided early on that I would take a gap year after high school, and one of my goals was to do a programming internship. In December, I sent out a few hopeful resumes, which depicted no experience other than some hobby projects on Github. I was surprised when a response came back, requesting an interview. Then...


Read More

Use Koala Ruby gem to post "gif" image

Use Koala Ruby gem to post "gif" image thumbnail

Koala is a famous gem for interacting with Facebook activity. Common interaction can be achieved with single simple method call. However, when we develop a Facebook feed poster for gif image, the gif image was not automatically played. Koala common usage For posting a plain text message to my Facebook feed: facebook_graph = Koala::Facebook::API.new(facebook_...


Read More

Best Practices: Manage database schema changes with Database Migration (and version control)

Best Practices: Manage database schema changes with Database Migration (and version control) thumbnail

When you develop software with a SQL database, there are code changes that requires database changes as well. It could be database schema changes (e.g. adding a new column) or data fixes (e.g. changing all existing user phone number format). While it is common to use version control to manage code changes, there still many development...


Read More

Prevent duplicated database record creation with find_or_create_by

When we developed the gaming App for our client Colors, we encountered a common data consistency problem: How to prevent duplicated database record creation. Of course everyone instantly can think of "use #find_or_create_by", but it is actually little bit more complicated than that. #find_or_create_by We are using Ruby on Rails to implement...


Read More