Gilang Mahardhika

Ruby Enthusiast, Scaling Maniac, Tech Researcher

Read this first

Using High Voltage to Serve Static Page Without Database and Controller in Rails App

When we create an app that provide some static pages, sometimes we use a resource called Page, save it in the table and call it from controller. Now, we have an alternative to make it without a database even without a controller by using High Voltage

Add high_voltage gem to your Gemfile

gem 'high_voltage', '~> 2.2.1'

After that, create a directory in your views called pages
app/views/pages

And then create your desired view in this directory, for example I want to create an about us page here, I create a file about.html.erb and fill html content here.

I can create a link to your page by using this
link_to 'About Us', page_path('about').
about is the page that I have created before, this will generate url like this http://localhost:3000/pages/about.

And Done!!

Continue reading →


Uploading images to Cloudinary using Rails and Carrierwave

Sometimes we need to upload our images to cloud storage like Amazon S3, but like me, I have a limitation because I don’t have any credit card or paypal account. Cloudinary gives us a chance to store our images with free plan (and also no credit card required).

After signed up to cloudinary with free plan, we’ve got cloud name and a pair of API Key and API Secret, it will be used for our application. Let’s create our app rails new cloudinary and add several gems to Gemfile

 add these following gems
gem 'cloudinary'
gem 'rmagick'
gem 'carrierwave'

then run the bundle command to install it.
After that, we need to define the cloudinary configuration by creating a file named cloudinary.yml in config directory

development:
    cloud_name:  put_your_cloud_name_here
    api_key:  put_your_api_key_here
    api_secret:  put_your_api_secret_here

production:
    cloud_name:
...

Continue reading →


Installing PHP, MySQL, phpmyadmin nginx on Ubuntu Server (part 2)

Next step, we are going to install phpmyadmin on ubuntu server. Type this command to install on your server sudo apt-get install phpmyadmin Please follow the instruction and if you find an option to choose the server (apache/lighthttpd), just choose one of them as you want.

After that, We can use one of the two options here to make your phpmyadmin can be accessed from browser.

The first option

After completed the installation, we have to make a symlink from phpmyadmin directory to nginx root directory by typing this command sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/www/. Done! You’ve just finished your phpmyadmin installation, you can access it on your browser by using your server url http://your-ip-or-domain/phpmyadmin.

The second option

After completed the installation, we have to change the nginx configuration. Open /etc/nginx/sites-available/default and add these...

Continue reading →


Installing PHP, MySQL, phpmyadmin nginx on Ubuntu Server (part 1)

First step, of course you should install a fresh ubuntu server on your server (both virtual or physical), and then install nginx by typing this command

sudo apt-get install nginx

Ok, once you have finished install nginx, then install PHP, we don’t use standard PHP anymore, but we move on to use PHP-FPM, install it by using this command

sudo apt-get install php5-fpm

Good! You’ve just installed it correctly. After that, you should configure your PHP-FPM configuration by following these steps:

  • open /etc/php5/fpm/php.ini
  • Find cgi.fix_pathinfo=1 and change the value from 1 to 0
  • open /etc/php5/fpm/pool.d/www.conf
  • find listen = 127.0.0.1:9000 and change its value to /var/run/php5-fpm.sock
  • uncomment listen.owner = www-data and listen.group = www-data
  • restart php-fpm: sudo /etc/init.d/php5-fpm restart

Let’s move back to nginx again, and we have to update its configuration.
open /et...

Continue reading →