Macbok M2 – Ruby on Rails installation – Problem [Solved]

Ruby – User RVM for Ruby installation and use ruby version greater than 3 for better performance.

Mysql:

Install via official site https://dev.mysql.com/downloads/mysql/

use youtube link how to install mysql here.

Add below line in ~/.bash_profile file :

export PATH=${PATH}:/usr/local/mysql-8.0.33-macos13-arm64/bin

where you may have to change mysql version in the path ie. mysql-8.0.33-macos13-arm64 to your mysql bin path.

It took more than 24 hours to solve this problem so I posted it in my blog here.

Thanks & Regards,

Manish Shrivastava

To upgrade ruby 2.x to ruby 2.7 and rails 4.x to rails 6.0

Ruby on Rails update

It’s very rare to directly update from ruby 1.8.7 or ruby 2.0 to ruby 2.7 and rails 4 to rails 6.0. As I have recently done many upgrade projects from legacy ruby code to new ruby code. So, I thought to help other developers too.

How?

To do so, I have got the advantage of working from Ruby 2.x to the current version of ruby to I know each and everything from legacy plugin development age to gems and then gems to new replaced gems(if depreciated).

What?

For a small project, I would rather suggest installing a fresh project in the latest ruby and latest rails there. Now, I will replace the app folder of the old code into a new project.

also, I will keep adding configurations carefully as it’s mainly updated.

GEMS:

Regarding other gems, go to their GitHub documentation and check if the community is active (check using the last commit), if yes then you can install with their latest version without setting the gem version. i.e. gem install devise and add gem 'devise' in your Gemfile.

Migration:

and most important is the GEMS, from the old file, remove all ruby and rails related gems to transfer as new rails is already installed.

In migrations, you will have to add `[6.0]` in migration.

Webpacker update:

Ideally, we should use webpacker with rails 6, but As most clients don’t give time to re-write the javascript code with webpacker. So, It’s better to use normal javascript as in-app/assets folder.

And

For better projects management, we should follow the process:

  1. Prepare the List of Decreciated gems. Identify all possible new gems which can be used also if required or not.
  2. Prepare the documentation of changes required.
  3. Prepare the timelines accordingly.
  4. Work on ROR update as per your plan.
  5. Always use another branch for any kind of upgrades. and never use the master branch for an upgrade.
  6. Try to write the test cases as well so that you will be sure about the functionality is working properly.
ruby on rails

Feel free to let me know if you face any issue or wish me to work on your ruby on rails update. I will be happy to assist.

Thanks,

Manish S

[Solved]: Incorrect datetime value: ‘0000-00-00 00:00:00’ for column

Problem faced: Incorrect datetime value: ‘0000-00-00 00:00:00’ for column.

Solution: The best way to do this is to export the MySQL dump file using below command from the database.

mysqldump -uroot -ppasswordname databasename > database_name.sql

Now, you have `database_name.sql` and try to open the file and search the string `0000-00-00 00:00:00` and replace it with `CURRENT_TIMESTAMP`. You can do that with below command:

sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' database_name.sql

Once in your file when you replaced all `0000-00-00 00:00:00` with `CURRENT_TIMESTAMP`. You can import that into new separate MySQL 5.7 installed separately successfully.

However, there are different suggestion at stackoverflow. You can go through this if you need.

That’t it. You can test that and let me know if anything.

Cheers