Hello World for Ruby on Rails

Posted by andy gaskell on Aug 15th, 2006

I’m just getting started with Rails so I went looking for a Hello World example. Eventually I came to this post. I’m going to go over the equivalent example using the RIDE-ME IDE.

1. Create a new project. Click File – New – Project.

2. Enter C:\ in the Location textbox. Enter HelloWorld in the project name. Click OK.

New Project dialog

3. Click File – New – Controller. Enter Hello for the name of the Controller. Click OK.

New Controller dialog

4. In the Project Explorer window, expand app, expand views. Right click the hello and click on Add New RHTML Page.

Adding a new RHTML page

5. Name the file index.rhtml. Click OK.

Naming the new RHTML page

6. Type “hello world” in your rhtml page. Save the file.

7. Press F5 (or click Run) and in a few seconds the web server starts and a browser window launches. Change the URL to http://localhost:3000/hello.

8. Hello World!

I hope to post more short projects as I work my way through the PickAxe and Agile Web Development with Rails books.

Setting a default button using Master Pages in ASP.NET

Posted by andy gaskell on May 2nd, 2006

This one’s pretty easy, but wasn’t apparent to me at first. Put this code in your Page_Load to set a default button in master pages:

this.Form.DefaultButton = this.YOUR_DEFAULT_BUTTON.UniqueID;

Formatting data in databound controls

Posted by andy gaskell on Apr 18th, 2006

I’ve been trying to format DateTime and currency in asp.net 2.0 databound controls (DetailsView and GridView). After some googling I was able to get it figured out.

To format DateTime values, you might expect to use a tag like this:

<asp:BoundField
     DataField="BeginDate"
     DataFormatString="{0:d}"
     HeaderText="Begin Date" />

and have a result like this:
10/10/2004

but instead you get a result like this:
10/10/2004 12:00:00 AM

Here’s the fix – add HtmlEncode=”false” to your BoundField tag:

<asp:BoundField
     DataField="BeginDate"
     HtmlEncode="false"
     DataFormatString="{0:d}"
     HeaderText="Begin Date" />

The same idea applies to formatting currency, I’m assuming other types of data formatting as well. Here’s Microsoft’s explanation.

Technorati Tags: , , , ,

-