Adding a side menu to your IOS App – RESideMenu Storyboard Tutorial – Part 1

In this tutorial, we are going to cover some of the quick and easy way of adding a side menu to your iOS app.

Basic Housekeeping

Firstly, let me introduce you to http://www.cocoacontrols.com, this is repository that provides a bunch of custom controls that are designed for iOS and Mac OSx. Sometimes we should not reinvent the wheel, but harness the power of the internet and community around.

Next, we are going use cocoa pods, if you are not sure what that is, head over to the following url -> Raywenderlich’s intro to cocoapod

So I have choose, RESideMenu, an amazing and beautiful control. GitHub – RESideMenu.

Getting Started – Adding RESideMenu to your project

  1. Adding the library into your project, if you have a pod file add the following:
    pod 'RESideMenu', '~> 4.0.7'
    
  2. Within your Terminal, browse to your XCode project location and type the following:
    pod install
  3. Xcode should generate a xcworkspace extension for you. Moving forward you should be only using this file.

Getting RESideMenu to work

Let create the following files in your project.

  1. RootViewController – Add New File -> Cocoa Touch Class
  2. HomeController – Add New File -> Cocoa Touch Class

The above should inherit UIViewController.

Next in your Main.Storyboard, add the following:

  1. UIViewController
    Searching for UIViewController
  2. UINavigationController

It should look like below after you are done.

Storyboard

In the next post, I am going to show you what we need to configure.

 

 

Tutorial – Building a Support Ticket System on Rails – Part 2

We are going to create the following in this tutorial:

  • Ticket Model
  • Ticket Controller
  • Ticket Views

Here we going to take the easy way out by having rails generate all the above for us, using a single command.

1. Open Terminal and key the following:

-> rails g scaffold Ticket ticketnumber:integer ticketTitle:string ticketDescription:string status:string date:datetime uid:string resolution:string

Now in the project directory, a lot of new stuff files are generated for you as well as configuration of routes are done up.

2. Now to create the table in the database

-> rake db:migrate

3. Now we need to set the default page that is going to be loaded by the application.

Browse to config/routes.rb, add the following line into the file.

-> root ‘tickets#index’

4. Next we want the application to validate that the user is signed before access any pages.

Browser to app/controllers/tickets_controller.rb, add the following line after the class TicketsController <ApplicationController.

-> before_action :authenticate_user!

5. Testing time!

-> rails s

Browse to http://localhost:3000/

 

Tutorial – Building a Support Ticket System on Rails – Part 1

From the start of this year, I will try to start writing more tutorial post instead of snippet of technology post.

For a start, I will be talking about the recent Support Ticket System that I build on Rails.

Duration: 30 mins

Let’s create a new Rails application.

1. Open up Terminal, enter the following command to generate the project

-> rails new SupportTicketSystem

This should generate all the relevant files and the necessary files structure.

2. Configuration of Devise

2.1 Access the project folder and locate the Gemfile, add the following line.

gem ‘devise’

We are going to use Devise here to help you manage your users. For more information on Devise visit the following,https://github.com/plataformatec/devise

2.2 Next up from the Terminal, access the folder and run the following command.

-> bundle install

In some case, due to how your machine is setup, you may need to run it will ‘rake’ infront

-> rake bundle install

2.3 Run the following command to setup Devise.

-> rails g devise:install

OR

-> rails generate devise:install

Both of the above does the same thing but the first option is a short hand method of rails.

2.4 Now we are going to specify the Users data so that Devise is aware of it and create the database table.

-> rails g devise User

->  rake db:migrate

To verify the above setup, go to app/models/user.rb

You should see the User.rb being created and that the context of the file should be similar to what I have.

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end

2.5 We going to add a new column to the User Model, call Type.

This type will allow the system to know if the user is a customer or a support engineer.

Now go to the terminal again.

-> rails g migration add_type_to_user type:string

-> rake db:migrate

Now you have added a new column to the database table!

2.6 Setting different user type via Enum. Open up User.rb in app/model

Add the following code:

enum type: [:SupportEngineer, :Customer, :Admin]

2.7 Lets generate some UI from Devise

-> rails g devise:views users

2.8 Controller!

-> rails g controller Users

Now go into the file, users_controller.rb in the following location, app/controller

We need to change the “ApplicationController” to Devise::SessionController

class UsersController < Devise::SessionsController
end

Now go to routes.rb in your app/config and make sure that devise_for:users is there.

2.9 Now to test 

In terminal, do the following command to start the server.

-> rails s

Open up your browser, http://localhost:3000/users/sign_up

Disable Google Chrome Outdated Prompt

Firstly, I am a Big Fan of Google Chrome and its have been my favourite browser choice.

But this little message box on Chrome have been bothering me a lot lately. To remove the outdate prompt do the following:

–allow-outdated-plugins

Append the above to the chrome.exe in the properties of the file.

If you have it pin to the taskbar like me in Windows

1. Unpin the existing shortcut
2. Run the new chrome and pin in back to the task bar.

OwnCloud : PHP 5.3.4 is required. Please ask your server administrator to update PHP to version 5.3.4 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.

If you are on bluehost, follow the steps below

1. Access the File Manager.

2. Make sure you check the Show Hidden Files option.

3. Select .htaccess and edit it.

4. Your original content of the .htaccess file

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php

Change it to the following

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php54s .php

5. Save it.

Turning on PHP 5.3 on Bluehost

Bluehost is a service provider for web hosting by default the php version is 5.2.

With certain installation on the server, you may need php 5.3 and this guide will show you how to do it.

1. Login to Cpanel, from the left of the screen you should be able to locate the current version of the instance.
PHP Version
For my case, its PHP 5.2.17, now we are going to upgrade this to php 5.3.
NOTE: this steps will work if you need 5.4

2. Under Software/Serivces, select PHP Config.

PhpConfig

3. Within Php Config. Select Php 5.3 and click Save at the bottom of the page.

OwnCloud… Your personal private Cloud. With Bluehost Setup Guide

If you are not sure what OwnCloud is head over to the following url:

http://owncloud.org/

Setting it up with Bluehost:

*Bluehost is a hosting provider, just happen to be the one i am using.

Easiest way, create a subdomain and upload the setup-owncloud.php file and you can take it from there.


1. Creating a subdomain

– Login to Bluehost
– Access the following url https://my.bluehost.com/cgi/dm/subdomain
– Create a subdomain. From my case, I input owncloud.mydomain.com

Make sure you have php 5.3 and above. Follow this link to turn it on

2. Uploading of the setup-owncloud.php

– Download the setup-owncloud.php from http://owncloud.org/install/ select the Web Installer
– Switch to your Bluehost Cpanel -> File manager
– Look under the WWW folder, you should have a folder created ask owncloud (or whatever name you gave previously for your subdomain)
– Now upload the setup-owncloud.php to this folder.

If you get the error after you make sure php 5.3 is turn on. Follow this link to dismiss the message

3. Installing OwnCloud

– Access the following url : http://owncloud.mydomain.com/setup-owncloud.php
*Note: replace the following url with your own values.

And we are good to go!

Happy Easter!