Marcus  Flatley

Marcus Flatley

1595503260

Automate Tasks in Rails Using the Whenever Gem

What is Cron?

Before we can jump in to using the whenever gem, we need to learn about Cron. Cron is a utility that is used to schedule commands at specified intervals, and is most likely already on your machine. It’s ideal for automating recurring tasks, called cron jobs. Cron jobs can be written directly in a config file called a crontab, however the syntax can be a little confusing (it’s a lot of asterisks):

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6)
# │ │ │ │ │                       
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>

Whenever gem

The whenever gem adds a layer of simplicity to cron jobs, and provides a much more readable syntax to writing them. Let’s set it up:

  1. Install whenever
gem install whenever

or add the following to your Gemfile and then run bundle

gem 'whenever', require: false

2. Create a **schedule.rb** file by running the following:

bundle exec wheneverize .

3. Set up your output

The schedule.rb file has some examples commented out for reference. One thing that needs to be added is where the cron jobs will be logged once they complete. We can put ours in cron.log, but this can be customized:

set :output, "log/cron.log"

This step is really important, because if you try and run a simple cron job, like printing something — it will get printed to wherever you set your output and _not _your terminal.

4. Setting up your cron job and interval

Whenever has wonderfully simple syntax — you can check the documentation for any specific interval needs. For our example, let’s do some task every minute:

every 1.minute do

#task will go here
end

Whenever offers a few different job types to express tasks. We will be using Rake, but check out all the options below:

  • runner “MyModel.some_process”
  • rake “rake:task”
  • command “/usr/bin/my_great_command”
  • You can also define your own job type. The instructions are outlined in the whenever documentation.

#ruby-on-rails-development #web-development #cron #ruby-on-rails #automation

What is GEEK

Buddha Community

Automate Tasks in Rails Using the Whenever Gem
Marcus  Flatley

Marcus Flatley

1595503260

Automate Tasks in Rails Using the Whenever Gem

What is Cron?

Before we can jump in to using the whenever gem, we need to learn about Cron. Cron is a utility that is used to schedule commands at specified intervals, and is most likely already on your machine. It’s ideal for automating recurring tasks, called cron jobs. Cron jobs can be written directly in a config file called a crontab, however the syntax can be a little confusing (it’s a lot of asterisks):

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6)
# │ │ │ │ │                       
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>

Whenever gem

The whenever gem adds a layer of simplicity to cron jobs, and provides a much more readable syntax to writing them. Let’s set it up:

  1. Install whenever
gem install whenever

or add the following to your Gemfile and then run bundle

gem 'whenever', require: false

2. Create a **schedule.rb** file by running the following:

bundle exec wheneverize .

3. Set up your output

The schedule.rb file has some examples commented out for reference. One thing that needs to be added is where the cron jobs will be logged once they complete. We can put ours in cron.log, but this can be customized:

set :output, "log/cron.log"

This step is really important, because if you try and run a simple cron job, like printing something — it will get printed to wherever you set your output and _not _your terminal.

4. Setting up your cron job and interval

Whenever has wonderfully simple syntax — you can check the documentation for any specific interval needs. For our example, let’s do some task every minute:

every 1.minute do

#task will go here
end

Whenever offers a few different job types to express tasks. We will be using Rake, but check out all the options below:

  • runner “MyModel.some_process”
  • rake “rake:task”
  • command “/usr/bin/my_great_command”
  • You can also define your own job type. The instructions are outlined in the whenever documentation.

#ruby-on-rails-development #web-development #cron #ruby-on-rails #automation

Marcelle  Smith

Marcelle Smith

1598839653

Authenticating Your API Using "Knock Gem" in Rails

Due to the inability to generate a well-defined way to authenticate rails API, I have sourced out this information in order to help me and you have a way of authenticating our rails API token. This tutorial would be based on the latest version (6.0) of Ruby on Rails.

In getting this set up as well as up and doing, the few steps through which the processes would be implemented are listed below:

Step 1:

We would need to, first of all, generate a new rails app as we embark on the journey. Follow the example given below:

$ rails new sample-app --api -d=postgresql -T
$ cd sample-app
$ rails db:create
$ rails db:migrate

Step 2:

In order to gain access to the API, we would need to uncomment or remove Cors gems as that serves as permission into gaining access to the API

gem “rack-cors”

After uncommented the gem ‘rack-cors’ then we run this command below

$ bundle install

#ruby-on-rails #rails #rails-api #knock-gem #ruby #software-development #rails-only-api

Origin Scale

Origin Scale

1620805745

Automation Management System

Want to try automated inventory management system for small businesses? Originscale automation software automate your data flow across orders, inventory, and purchasing. TRY FOR FREE

#automation #automation software #automated inventory management #automated inventory management system #automation management system #inventory automation

Why Use WordPress? What Can You Do With WordPress?

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:

1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

3. Create A Forum For Your Brand’s Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.

Read More

#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website

Ruby on Rails Development Services | Ruby on Rails Development

Ruby on Rails is a development tool that offers Web & Mobile App Developers a structure for all the codes they write resulting in time-saving with all the common repetitive tasks during the development stage.

Want to build a Website or Mobile App with Ruby on Rails Framework

Connect with WebClues Infotech, the top Web & Mobile App development company that has served more than 600 clients worldwide. After serving them with our services WebClues Infotech is ready to serve you in fulfilling your Web & Mobile App Development Requirements.

Want to know more about development on the Ruby on Rails framework?

Visit: https://www.webcluesinfotech.com/ruby-on-rails-development/

Share your requirements https://www.webcluesinfotech.com/contact-us/

View Portfolio https://www.webcluesinfotech.com/portfolio/

#ruby on rails development services #ruby on rails development #ruby on rails web development company #ruby on rails development company #hire ruby on rails developer #hire ruby on rails developers