Ajax pagination in Ruby on Rails

Ruby on Rails, 2015-06-17 00:04:29 UTC
Before We begin creating an ajax pagination, We need to know the concept of ajax and pagination. In my opinion, the main concept of ajax technique is requesting data in the background and catch the response. In this concept, after the browser receiving the data from the server, the response will rep

Ruby on Rails configuration on a production server

Ruby on Rails, 2015-06-17 00:03:58 UTC
This tutorial is based on my experience on the Ubuntu-Apache server. To configure it, first you must have Phusion Passenger on your machine and follow these steps; 1. Create a virtual host configuration file in "/etc/apache2/sites-available" folder $ sudo nano /etc/apache2/sites-available/app_nam

Using specific layout via the controller

Ruby on Rails, 2015-06-16 23:21:20 UTC
Layout placement is very important for Ruby on Rails application. Without layouts, the application looks bad. These ways to create layout via the controller; 1. This is a controller example class ExampleController < ApplicationController layout "my_layout" def index end def sesuatu end end Above code will be define as a layout for all of method in the controller 2. Layour for specific method class ContohController < ApplicationController layout "my_layout", only: [:index, :new, :create] def index end def another_method end def new end

Step by step authentication with Devise in Ruby on Rails

Ruby on Rails, 2015-06-16 23:09:58 UTC
1. Preparing your gem gem 'devise',: git => 'https://github.com/plataformatec/devise.git',: branch => 'lm-rails-4-2' 2. Run the following command $ bundle install 3. Install devise $ rails g devise:install 4. Add the following line to /config/development.rb config.action_mailer.default_url_options = {host: 'localhost', port: 3000}

Override Rails Table name

MySQL, Ruby on Rails, 2015-05-24 01:48:39 UTC
I don't know exactly what does this name in Rails. But, I named it override table name in Rails. The case is very simple, let say We already have a table name in the database. The database name is email_dr_pengunjung. When We create it with rails g model command, Rails simple add s in the end of table name. So, the table name is email_dr_pengunjungs and the migration file like 20150523233040_create_email_dr_pengunjungs.rb $ rails g model EmailDrPengunjung Just open up 20150523233040_create_email_dr_pengunjungs.rb to force using 'the old table name'. And add these lines; class CreateEmailDrPengunjungs < ActiveRecord::Migration def change self.connection.execute %Q( CREATE TABLE IF NOT EXISTS `email_dr_pengunjung` ( `id` int(10) NOT NULL AUTO_INCREMENT, `email` varchar(255) DEFAULT NULL, `nama_lengkap` varchar(255) DEFAULT NULL,