Wednesday, July 25, 2018
no implicit conversion of nil into String
This can happen when you have not defined the required configuration in secrets.yml. For instance, you are using http basic auth and the credentials are not defined in the config file.
Tuesday, July 24, 2018
Wednesday, July 18, 2018
Tuesday, July 17, 2018
Thursday, July 12, 2018
Sprockets::FileNotFound: couldn't find file 'fingerprintjs2' with type 'application/javascript'
jquery_ujs Uncaught TypeError: $.ajaxPrefilter is not a function
This happened when I copied the started template from Bootstrap 4.1 version. It gives you the slim version of jQuery by default. Use the regular jQuery. https://code.jquery.com/jquery-3.3.1.min.js
In style.scss, include
@import bootstrap
Copy the bootstrap.js to vendor/assets/javascripts directory. Copy bootstrap.css to vendor/assets/css directory.
This happened when I copied the started template from Bootstrap 4.1 version. It gives you the slim version of jQuery by default. Use the regular jQuery. https://code.jquery.com/jquery-3.3.1.min.js
In style.scss, include
@import bootstrap
Copy the bootstrap.js to vendor/assets/javascripts directory. Copy bootstrap.css to vendor/assets/css directory.
Sunday, July 08, 2018
Overcoming Mental Hurdles to Software Development
Facing Too Many Unknowns
Gaining Momentum
I was able to gain momentum by tackling simple tasks related to that feature. Refined the requirements and the user's flow over a few days to come up with more followup questions to finalize the requirements. Once the requirements became clear, I was not coding based on some phantom requirements and designing the complicated database structure that was not even required. The time spent on solving problems that did not exist was very energy draining. I had already spent time on analyzing the flow that could vary due to three variables. This made the solution very complex due to the amount of variations. The code was becoming a big mess.
Focusing on the Core
I drew simple diagrams with boxes and arrows to show the user's flow for different use cases. Discussion with the stakeholder had a structure because we focused only on one use case at a time. There was no discussion of technology during this conversation. Only golden path scenario was discussed to clarify the requirements. We can add the alternate scenarios later. We can ask questions based on the existing diagrams, reason about what should happen and draw the alternate scenarios separately.
Gaining Business Context
I made the mistake of copying the similar features of other existing products. I realized it was a mistake later because the business context was different. During the conversation based on simple diagrams I was able to understand the business context. I had narrowed the scope of the problem to be solved. I also pushed back on some requirements and asked the stakeholder to justify why it should be included in version 1. Some of the things might happen once every 3 months does not justify automation and was removed from the stated requirements.
Building a Prototype First
I did not build a prototype because it was a lot easy to use Bootstrap 4.1 with Rails to build the screens with hard coded data. I saved the time to learn a prototyping tool. I was able to focus on learning new AWS APIs that was required to build the product.
Being Agile and Lean
The client was remote and was able to chat via What's app and email few times a week. The requirements were in the emails and were not well thought out to write the test first. Clarify First, Test Later. I did not automate the infrastructure management because at this point I am not sure if I can get 99 clients who will find this product useful without any customization. It has been custom built for this particular client. Reading the lean startup articles, I was confident that I was targeting the right segment in the adoption curve.
Lessons Learned
- Do not write production level code before understanding the business.
- Draw simple diagrams with technical details to gain business context first.
- Narrow down the scope of the problem before starting to code.
- It's ok to start the first few versions of the screen with existing products from similar domains.
- Remember, these screens need to refined once the business context knowledge is acquired.
- If the complexity of the solution is getting out of control, go back and see if you can push back on the requirements.
Saturday, July 07, 2018
Friday, July 06, 2018
Web Apps and MVC
These diagrams explain the flow of the web app for different use cases. These diagrams can easily be understood by stakeholders with no technical background. The conversation based on these diagrams are useful to understand the requirements and clarify any vague requirements.
This flow is also useful when developing a MVC based Web app. Because these use cases can span across different controllers and each controller can be shared by different use cases. It provides a structure and minimizes the rework required in later stages after the app is deployed.
This flow is also useful when developing a MVC based Web app. Because these use cases can span across different controllers and each controller can be shared by different use cases. It provides a structure and minimizes the rework required in later stages after the app is deployed.
Wednesday, July 04, 2018
Tuesday, July 03, 2018
Running Jobs in the Background
1. Active Job Async
Configure queue_adapter in config/application.rb:
config.active_job.queue_ adapter = ActiveJob::QueueAdapters:: AsyncAdapter.new
min_threads: 1,
max_threads: 2 * Concurrent.processor_count,
idletime: 600.seconds
2. Use perform_later when you send the email.
3. Linode $5 box has one core:
$ grep -c ^processor /proc/cpuinfo
1
References
Automatic Renewal LetsEncrypt SSL Certificate
sudo certbot renew --dry-run
If this does not show any errors, your SSL will be renewed automatically. Reference:
How To Secure Apache with Let's Encrypt on Ubuntu 16.04
Install Wild Card SSL using LetsEncrypt on Apache
Monday, July 02, 2018
Run commands on server using Capistrano 3
Add :
require 'capistrano/console'
to Capfile
Now you can run:
This allows you to run commands on the server terminal. Useful to run commands like: uptime.
require 'capistrano/console'
to Capfile
Now you can run:
bundle exec cap production console
This allows you to run commands on the server terminal. Useful to run commands like: uptime.
How to tail production log in Capistrano 3
1. Add:
to lib/capistrano/tasks/tail.rake.
namespace :logs do
desc "tail rails logs. Usage cap production logs:tail_rails"
task :tail_rails do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end
2. You can now tail the production log from your local machine:
cap production logs:tail_rails
to lib/capistrano/tasks/tail.rake.
namespace :logs do
desc "tail rails logs. Usage cap production logs:tail_rails"
task :tail_rails do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end
2. You can now tail the production log from your local machine:
cap production logs:tail_rails
How to configure Capistrano 3 to play with Rails staging / production console
1. Add:
gem 'capistrano-rails-console', require: false
to Gemfile and bundle.
2. Add:
require 'capistrano/rails/console'
to Capfile.
3. Run:
cap production rails:console
to play in production rails console.
gem 'capistrano-rails-console', require: false
to Gemfile and bundle.
2. Add:
require 'capistrano/rails/console'
to Capfile.
3. Run:
cap production rails:console
to play in production rails console.
Sunday, July 01, 2018
Make Capistrano Run Migration on Deploy
Make sure you have the db role in the
config/deploy/production.rb file as follows:
:
server 'ip-address-goes-here', user: 'deploy-user', roles: %w{app web db}
Sending email in production in Rails apps
In controller:
PurchaseNotifierMailer.send_purchase_confirmation_email(@user).deliver!
In production.rb:
config.action_mailer.smtp_settings = {
user_name: 'sendgridusername',
password: 'sendgridpassword',
domain: 'yourdomain.com',
address: 'smtp.sendgrid.net',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
Subscribe to:
Posts (Atom)