How to create Ruby on Rails Application

  • I am developing RoR applications on Windows 7.
  • Assuming that you installed Rails framework on your system before creating application.

Type rails as shown in screenshot and click on command prompt for Rails framework.

Now being a php developer i already have XAMPP installed on my machine and i want my projects to come under the htdocs.
I created a new directory in htdocs as railrepo to store my rail projects. I am naming my first project as project1.

Check this screenshot for directory structure –

Now under railrepo directory I am creating my First rail project(project1) using new command.

rails new project1

Type this command under your railrepo folder as shown in sceenshot-

Once you are done with files creation, you are expecting this to show on your browser. For this you need to start rails server first. Type this command in the folder you created your application by opening another command prompt window.

Command – rails server

Check the screenshot –

Once your rails server started check the action in your browser, by typing —

localhost:3000

Check the screenshot as well–

Search and replace within a column in mysql

In my codeigniter project I need to add slug field in the database from name column. This is what i did –

First of all i created a field name “slug” just after ename column and copied that content of ename to slug, using this query-

UPDATE default_event
SET `slug` = `ename`;

Then i fire this query to replace blank spaces with “-” to form links-

UPDATE default_event
SET slug = replace(slug, ‘ ‘, -‘);

Difference between echo and print in php

echo and print are both language construct in php, however print returns 1 but it is not a function.

Below mentioned usage of echo and print, both are valid

echo "Hello World"
print "Hello World"

echo("Hello World")
print("Hello World")

echo can output more than 1 string while print cannot(using comma separator)

echo "Hello", "world","I am Swapnesh";
print "Hello";
print "World";