gitignore template for a Ruby on Rail project

Been working with Ruby On Rails for about 10 months now, about the same amount of time with GIT, I enjoy them both very much.

When I start a rails project and connect it to GIT, I always create the same gitignore file. Therefore, I thought I should share it with you.

Here it is:

log/*
tmp/*
.DS_Store
db/*

Enjoy!

Link Bag September 05 2010

Yet another post that will gather links and useful information of intersting stuff, that will probably be useful to my readers.

General

Launching beta, or “How to decide when and where to cut corners – A great post from CodeBetter.com with a reference to Nate Kohari’s post on the same subject. A very good read if you are planning in launching a product anytime soon.

Freelancing

10 Requirements for Working with Clients in Other Countries – I work with clients in other countries all of the time, mostly in the US and Japan. Therefore, I think this post will be very useful if you are in the same situation. I got something out of it, and so will you.

Craftsmanship in Designing Websites – I am into software craftsmanship, until I read this post I didn’t know there’s a movement towards craftsmanship in design as well. Good read.

CSS

CSS: Stretch a Box to its Parent’s Bounds – A post by my good friend, @elado, a great css technique.

GIT

I am (as you already know) a huge fan of Git. I know Git is a big source of misuse and misunderstanding. I have read a couple of great posts about it recently on how to use GitK tool.

use-gitk-to-understand-git.aspx – The first post in the series.

Use gitk to understand git – merge and rebase – Great stuff, great screenshots (even through it comes from a windows machine :-) )

That’s all for now. Hope you’ll find my post useful.

Maintain sort on a DataGrid when the dataProvider is changed

Usually, in our Flex application we do have a data-grid. This component is very useful for displaying data and have a sorting, ordering of columns and more, out of the box.

I can speak for my applications and say that every enterprise application I have ever build had at least one or more data-Grid’s inside it.

So, what can we say about a grid that has not been said before in the past…?

I recently had a grid that I enabled sorting on it. It had a data-Provider (ArrayCollection) and I needed to preserver the sorting when the collection had changed.

The default behavior when you hookup a collection to the dataProvider property of the grid, is that when the collection changes, it will change the sorting back to default.

This is the code before the fix:

			<mx:DataGrid  width="100%"
							height="100%"
							id="dataGrid"
							dataProvider="{myHelper.widgetModel.data}"
							itemClick="myHelper.updateCustomFieldsButtonBar()"
							allowMultipleSelection="true"
							updateComplete="myHelper.gridUpdateComplete(event)">
				<mx:columns>
					<mx:DataGridColumn dataField="id" headerText="id" visible="false"/>
					<mx:DataGridColumn dataField="name" headerText="Field Name" />
					<mx:DataGridColumn dataField="description" headerText="Description" />
					<mx:DataGridColumn dataField="typeDisplayName" headerText="Type" />
					<mx:DataGridColumn dataField="entityTypes" headerText="Entity Type" />
					<mx:DataGridColumn dataField="listId" headerText="Entity Type" visible="false"/>
				</mx:columns>

			</mx:DataGrid>

This peace of code it the most important peace in the puzzle, wiring up (binding) between a model (collection) and the dataProvider:

dataProvider="{myHelper.widgetModel.data}"

So, we know that this way does not work.
What do we need to do in order to save the sorting when the provider changes?
What we actually need to do is to create a view of our collection, provide it with data and wire it up to the grid

This is how we do it.

<mx:ListCollectionView list="{helper.widgetModel.data}" id="listCollectionView" />

			<mx:DataGrid  width="100%"
							height="100%"
							id="dataGrid"
							dataProvider="{listCollectionView}"
							itemClick="myHelper.updateCustomFieldsButtonBar()"
							allowMultipleSelection="true"
							updateComplete="myHelper.gridUpdateComplete(event)">
				<mx:columns>
					<mx:DataGridColumn dataField="id" headerText="id" visible="false"/>
					<mx:DataGridColumn dataField="name" headerText="Field Name" />
					<mx:DataGridColumn dataField="description" headerText="Description" />
					<mx:DataGridColumn dataField="typeDisplayName" headerText="Type" />
					<mx:DataGridColumn dataField="entityTypes" headerText="Entity Type" />
					<mx:DataGridColumn dataField="listId" headerText="Entity Type" visible="false"/>
				</mx:columns>

			</mx:DataGrid>

Notice that the grid’s data provider is not the collection view.

Now, when the data will change, the sorting will not change.

Good luck!