Displaying Something from The Database

Guys in this tutorial I will explain you how to fetch values from the database and show those in a Table format.

Here I assumed one thing, that the user is logged in. and that user has the rights to delete a particular record from the table.

NOTE: This tutorial is very old. But will glimpse you how you can format your data in a structured manner.

So are you Guys Ready???? Then Let’s Start……..

Note: This will start the session of that particular user.


Advertisements

Rails 3: Polymorphic Associations in Action

Hi Folks,

In this short article, I would like to brief about “Rails polymorphic associations“. Below are the high-level pointers.

  • What is Polymorphic Association
  • How Rails handles it
  • Example explained
  • Demo

So, Let’s start:

  • What is Polymorphic Association: In OOP, Polymorphic means “of-many“.

There is a well documented and well explained Railscasts for this. Refer to this link for more information: http://railscasts.com/episodes/154-polymorphic-association

  • Example Explained:

Code snippet can be downloaded from Github. The path for the same is: git@github.com:puneetpandey/rails3_singleTableInheritance.git

Once set-up. Type the URL’s below:

  1. http://localhost:3000/events
  2. http://localhost:3000/users

How to submit your iOS application to Apple store

Hi Folks,

For all the iOS developers, who are developing an iOS application and now would like to submit their app to Apple store, all you need is to follow the below steps.

The article is updated according to the latest deployment changes introduced by Apple from March 1, 2013 onwards.

Prerequisite

1. Distribution Certificate

2. Provisioning Profile

3. Xcode 4.6.2

4. iOS 6 and above

5. Mac OS 10.8

6. An iPhone or iPad.

NOTE: I can’t cover how will you get the Distribution and Provisioning certificates and profiles, but in short I’ve created my account on developer.apple.com and the client for whom I worked with, has added me and provided me all the required certificates. But, if you would like to create your own, please read out apple documentation.

1 Distribution certificate: log-in to you developer.apple.com account. Go to -> Certificates, Identifier and Profiles under iOS Developer Program.

  • Click on ‘Certificates’ under iOS Apps.
  • Show the full list under ‘Certificates’ and click on ‘Distribution’.
  • You’ll find a Distribution Certificate (as Type). Download it.
  • Double click on it. It will be open in your ‘Key Chain‘ utility under ‘My Certificates‘.

2. Provisioning Profile: Follow step 1 of Distribution certificate.

  • Click on ‘Certificates’ under iOS Apps.
  • Show the full list under ‘Provisioning Profiles’ and click on ‘Distribution’.
  • You’ll find Distribution Provisioning Profile (as Type). Download it.
  • Double click on it. It will be open in your Xcode.

3. Attach your device with you Mac system and make sure it comes under your ‘Xcode Organizer’ menu.

4. Please keep in mind of below pointers:

  • Make sure your build is clean.
  • Make sure you’ve re-run your build once it’s cleaned.
  • Make sure you’ve run your build on the device to ensure everything is working fine. Because failure of just 1 piece of functionality will not allow you to submit your app to Apple store.
  • Make sure you’ve defined all the dependencies of your application (for e.g. Camera, Maps etc.). Because, when apple reviews your application, it checks weather all the dependencies all defined or not!

5. Your application submission depends on the below steps (we will cover each in detail):

  • Select your connected device near the ‘Run’ button.
  • Set the command line build to Distribution from the drop-down menu.
  • Open info.plist and change the bundle identifier to the appropriate one.
  • Make sure all the launch images are configured/defined properly.
  • Ensure to define distribution certificate under ‘Build Settings’ for Distribution entity.

6. Once all the checks are done. Go to ‘Edit Scheme’ -> ‘Archive’ and change the build configuration on the same window to Distribution.

7. Click on ‘Product’ -> ‘Archive’. This will clean, re-build your application. If no errors found, a new window will open (go to step 8). If error occurs (follow step 4 and 5).

8. You’re almost at the end. In the new window, 2 buttons will be there:

  • Validate and
  • Submit
  • Validate checks if all the required dependencies meet + builds your application
  • Submit validates your application. Requires itnues connect credentials.

I’ll add the necessary screenshots very soon.

Let me know if this article is helpful or need any modification.

Puneet Pandey

Rails 3: Single Table Inheritance

Hi Folks/Fellow Developers,

As I’ve seen lot many examples, articles over Single Table Inheritance, I decided to write my own. Thanks to the open source contributors. Their Articles/Examples helped me a lot writing this post.

As you might know about single table inheritance, let me quickly set the definition for it. Single-Table-Inheritance (STI) allows you to write/create sub-classes of a specific model. You can use a single table, add specific objects and extend the functionality/behavior of base model.

Current example explained:

My Current example is based on Mobile system. We have a single model called ‘Mobile’ and other models such as ‘Samsung’, ‘Apple’, ‘Nokia’ etc., that inherits the property of Mobile model. (Refer to the image for more help)

Single Table Inheritance
Single Table Inheritance

Development Platform used:

Ruby - 1.9.3
Rails - 3.2.13
Bundler- 1.3.5
DB - MySQL
IDE - Netbeans 6.9.1

The application is currently hosted on GitHub and can be cloned using the below command:
git clone git@github.com:puneetpandey/rails3_singleTableInheritance.git

Let me know your feedback about this application.

Happy Coding!
Puneet