We ♥ web applications!
At mobalean we love to build innovative web services for Japan and the world. Our experience will help transform your ideas into successful online services.
At mobalean we love to build innovative web services for Japan and the world. Our experience will help transform your ideas into successful online services.
Mobalean is lead by Henri Servomaa, the original founder and mobile developer. At Mobalean we strive to develop services which are loved by our clients and users. By working in an agile manner, quickly adapting to changing requirements, we can deliver quickly and often.
Hailing from Finland, Henri has a long history with computers and the internet. With a background in Electrical Engineering and Computer Science, he has worked in Japan as Software Developer and System Admin since 2001. In 2005, he joined a company to develop mobile sites for the Japanese market and has been involved in mobile ever since.
Cleve Lendon is a Canadian engineer who has been contracting for Mobalean. He came to Tokyo in 1994, and has lived here ever since. He has broad experience as a software developer, which includes development of mainframe software, Internet applications and mobile apps (Android and iOS). He is especially skilled at writing Java applications (vd. Simredo 4, Grafikilo 15). When not programming, Cleve enjoys improv acting and studying languages, such as Latin and Esperanto.
Our strength is crafting web services for both Japanese and international markets. We bring our technical and cultural experience to help you adapt your ideas into successful products.
We develop with Ruby on Rails and use the best agile practices and tools, such as test driven development and continuous integration to achieve quality.
We are the leading provider of technical expertise about the Japanese mobile web. Mobalean started when the smartphones were just appearing on the market. Our Keitai Web Technology Guide is a quick starting point for learning about the initial challenges of Japanese mobile development. Although the technology stacks have changed since the proliferation of iOS and Android, some of the idiosyncrasies remain. Most notably, the Japanese market is still very much dominated by the big three carriers: DoCoMo, au and Softbank. Developers can find more technical details in our Keitai-Dev Wiki.
Email address: [email protected]
If you prefer to call us, feel free to do so under +81 (0)70-6251-7245
For users of Skype, please call mobalean
Recently the boss asked me to upgrade one of our Rails applications. It was a Rails 3.2 app running on Ruby 2.1, which is, as I write, about 8 years old. He suggested upgrading to Ruby 2.4. Why not upgrade to the latest, Ruby 3.0? That might have been a leap too far.
I decided to upgrade to Ruby 2.5 and Rails 5.2. The upgrade did not go as smoothly as I had hoped. The Ruby language upgrade (2.1 to 2.5) presented no problems, but upgrading Rails from 3.2 to 5.2 was a major task. There were many deprecation issues and changes in syntax. Also, due to external dependencies, we had to move the app to a newer server, which brought more surprises.
I will discuss a few of the issues below. Perhaps this will be useful to other Rails developers who need to do similar work. I will assume that the reader is familiar with Rails development.
Unlike real gems, Ruby-language gems do loose their luster with age. Some gem upgrades were simple. For example, factory_girl (a gem used for testing) now identifies as factory_bot. In the Gemfile, I replaced,
gem "factory_girl" gem "factory_girl_rails"
with
gem "factory_bot" gem "factory_bot_rails"
...and ran the 'bundle install' command. No further issues there.
Upgrading twitter-bootstrap-rails was more time consuming. In Gemfile, I replaced,
gem "twitter-bootstrap-rails", "~> 2.2.8"
with the latest
gem "bootstrap"
This upgrade, from Bootstrap 2 to Bootstrap 4, completely messed up our CSS.
Some deprecated CSS classes could be fixed by simple replacement. I replaced the old span-classes (span2, span9, etc.) with col-md-2, col-md-9, and so on.
Fixing the Bootstrap navbar was not so easy; it required a lot of rewriting. If you have to do this, this reference is helpful: Bootstrap 4 Navigation Bar
The acts-as-taggable-on gem is widely used to tag related items in a database. There is a good intro here.
We jumped from version 2 to version 7, so of course, something had to break.
While submitting data to the database, the application threw out this error:
ActiveModel::MissingAttribueError in.... can't write unknown attribute 'taggings_count'
Acts-as-taggable-on uses two tables in the database: tags and taggings. My solution was to create a migration to add a taggings_count column to the tags table.
rails generate migration add_taggings_count_to_tags taggings_count:integer
The contents of the migration file were:
class AddTaggingsCountToTags < ActiveRecord::Migration[5.2] def change add_column :tags, :taggings_count, :integer end end
After running 'rails db:migrate', our acts-as-taggable-on gem was shining like new.
Like everyone else, we use ActiveRecord to interact with the relational database. There have been some syntax changes in ActiveRecord since version 3.2. Here are some differences which 'git diff' output:
- symbols = Symbol.find(:all, :order => :ordering) + symbols = Symbol.order('ordering') - @next ||= Compound.find(:first, :conditions => ['position > ?', position], :order=>'position') + @next ||= Compound.where('position > ?', position).order('position').first
In Rails 5, database migrations now have version numbers. In order to get Rails to accept old migration syntax, I put [4.2] at the end of ActiveRecord::Migration, in every migration file, as the git diff below shows:
-class RemovePathFromMutants < ActiveRecord::Migration +class RemovePathFromMutants < ActiveRecord::Migration[4.2] def self.up - Mutant.all(:conditions => "image is not null").each do |j| + Mutant.where("image is not null").each do |j| j.update_attribute :image, j.image.gsub("imgsmall/", "") end end
Of course, other changes were needed: 'all' was replaced by 'where'.
We use the 'mina' gem for deployment. Generally, we are happy with it. (Reference here.) Our old version was, I believe, 0.3.8. The current version, 1.2.3, required some modifications to our deployment script, config/deploy.rb.
I replaced :environment with :remote_environment,
task :deploy => :environment do
becomes
task :deploy => :remote_environment do
'set_default' was deprecated. I replaced it with 'set':
set_default :rbenv_path, "\$HOME/.rbenv"
becomes
set :rbenv_path, "\$HOME/.rbenv"
The 'set' command sets a 'configuration variable'. In the old script, configuration variables could be used directly in the deployment script. For example:
set :deploy_to, '/path/to/app' set :app_path, '/path/to/app/current' set :port, '9292' queue "cd #{app_path} && RAILS_ENV=#{env} DEPLOY_TO=#{deploy_to} PORT=#{port} script/puma restart"
This no longer works. It is necessary to fetch the configuration variables to use them:
set :deploy_to, '/path/to/app' set :app_path, '/path/to/app/current' set :port, '9292' deploy_to = fetch(:deploy_to) app_path = fetch(:app_path) port = fetch(:port) command "cd #{app_path} && RAILS_ENV=#{env} DEPLOY_TO=#{deploy_to} PORT=#{port} script/passenger restart"
Notice that 'queue' has been replaced with 'command'.
Finally 'to' was replaced by 'on':
to :launch do
becomes
on :launch do
You may have noticed in the deploy script above that I replaced 'puma' with 'passenger'. (Puma and Passenger are both popular webserver gems.) Why?
Originally our app used Puma 3.6. In our configuration file, config/puma.rb, the daemonize flag was set to true:
daemonize true
This option has been removed from Puma 5.0, because 'there are better options available'. (Thanks guys.) The option which I chose was to switch to Passenger 6.0.7, which has a command line option, --daemonize. To start Passenger, our deployment script runs:
bundle exec passenger start --port \$PORT --pid-file \$PID_FILE --user xxxx --daemonize
Our application was running on a Debian 7 Linux system ("Wheezy"), which is now eight years old. When I tried to deploy the staging version of the app on this machine, I discovered that the deployment process requires the Javascript V8 engine. NodeJS contains the V8 engine, so I installed that. Because Wheezy is old, the latest version of Node which I could install was v6.
The deployment program threw out this helpful message:
rake aborted! Autoprefixer doesn’t support Node v6.15.0. Update it.
The old server is scheduled to be shutdown anyway, so instead of trying to upgrade we moved the app to a newer server (Debian 8 / Jessie). I installed Node v10 on Jessie, which resolved this issue. Upgrading Jessie is on the TODO list next.
Rails applications implement an 'asset pipeline' in order to increase efficiency. All CSS files are joined together and minified (spaces and comments removed). The same is done with Javascript files. The resulting files, application.css and application.js, are saved in the public/assets folder of the app.
It is quite common to set up a reverse proxy server in front of the Rails app. The proxy, in our case Apache server, serves files in the assets folder itself, and passes other html requests on to the Rails app.
This is done because Apache servers are much faster than Rails apps, so letting Apache handle the fixed assets decreases loading time.
When I moved our Rails application from Wheezy to the new server, Jessie, I used the same Apache configuration file. (Configuration files are stored under /etc/apache2/ .) The app worked, except for the fact that Apache was not serving assets.
It turned out to be a configuration issue. Old Wheezy had Apache 2.2 installed. Jessie had version 2.4. In Apache 2.4, the Order and Allow options have been replaced by Require:
Access control config for Apache 2.2:
Options FollowSymLinks -MultiViews AllowOverride None Order allow,deny Allow from all
Access control config for Apache 2.4:
Options +FollowSymLinks -MultiViews AllowOverride None Require all granted
This problem was difficult to discover, because the configtest command:
sudo apachectl configtest
returned 'Syntax OK'. It gave no warning that Order and Allow had been deprecated. Live and learn. If you need to upgrade Apache from 2.2 to 2.4, this reference should be useful: Upgrading to 2.4 from 2.2
It is hard to estimate how long an upgrade will take, but if you are asked to upgrade a sophisticated web app, which has not been updated in 8 years, expect a rocky road.