Posted at 11:59 PM | Permalink | Comments (2)
Last night I presented an implementation of a calendar in ruby with Grant. I reviewed Grant's code while he reviewed mine.
It was a lot of fun and I really enjoyed the experience. Almost like a roast, but with code. I struggled a bit through the presentation with how things were being implemented and with relaying the problem that we were solving to the audience.
Afterwards Scott informed me that a better way to begin this presentation would have been to start with the client code, the use of the solution. What is your code allowing to happen. How is it being used. This information will at least let people up front know what is up and why you have written your code. Tests can do this for you, but if you could show this in the context of a real world example it will stick in their mind.
I thought about this and think that it is how I will begin technical demonstrations for the foreseeable future. Give people the reason, give them the why and then show the how. Otherwise the audience will lose patience and just start twittering.
Posted at 09:51 AM in Ruby | Permalink | Comments (0) | TrackBack (0)
I spent a long time tonight trying to figure you why I couldn't make autotest work with rspec. I was eventually able to make it work, but when reading the rspec changelog I noticed this tidbit.
Continue reading "ZenTest autotest is now autospec for rspec" »
Posted at 02:52 AM in Ruby | Permalink | Comments (1) | TrackBack (0)
We are setting up a couple of our blogs at wprj to be posted on www.mtmjobs.com
Posted at 11:49 AM | Permalink | Comments (0) | TrackBack (0)
Well I really liked the UpdateFrom method that lived in System.Web.MVC.BindingHelperExtensions. I dug it all the way back when it was actually an extension method, but the latest version of ASP.NET MVC Preview 5 has kicked it out. I haven't read it anywhere but microsoft seems to desire that we think of viewdata as being an extension of the model. So now you use UpdateModel and so you switch it up by passing the form keys so that it knows what properties to update, not a name value collection.
This really isn't that big a deal as far as fixing your code. I resolved my issues using a find and replace in visual studio using regular expressions. For the find I used BindingHelperExtensions.UpdateFrom\(({:w}), Request.Form\); and for the replace I used UpdateModel(\1, Request.Form.AllKeys);. As I need to do more I will make note of what is needed to get Preview 5 rolling.
Posted at 01:50 AM in .NET | Permalink | Comments (0) | TrackBack (0)
I just got my new macbook pro, so after I pulled down Textmate I was ready to start hacking on rails. I fired up the command prompt and did a "sudo gem update" to get up to rails 2.1 so I could use git plugins and other great new features. Well right after I kicked that off I started to get "can't find header files for ruby". To fix this all you need to do is install xcode. Also make sure you do that you do a gem install rails to get activeresource. After this you should be good to go.
Posted at 10:57 PM | Permalink | Comments (0) | TrackBack (0)
Over the past year I have grown quite a bit as a developer and realized that I should talk more about being open to expanding your knowledge outside of the technologies you are currently comfortable with. One year ago I was a ASP.NET C# webform developer that didn't know exactly why people didn't like ASP.NET and considered it a leaky abstraction.
Posted at 12:42 AM in .NET, Ruby, Web/Tech | Permalink | Comments (0) | TrackBack (0)
The Tulsa.rb group will be hosting a workshop on April 28th, 2008 from 10:00 AM to 4:00 PM. They are going to be covering some great topics especially for people extremely new to ruby.
Posted at 10:00 PM in Ruby | Permalink | Comments (0) | TrackBack (0)
Ran into a situation today where I wanted to render a ViewUserControl from my controller. I had a couple of hard times getting this done with the Microsoft MVC CTP1, but finally have it working. We did this to support using the Prototype observe to get behavior similar to a cascading drop down.
<% using (Html.Form<Web.Controllers.PlaqueOrderController>
(action => action.Create())) { %>
Season:
<p>
<%= Html.Select("SeasonId", ViewData.Seasons, "Name", "Id")%>
</p>
Statistic:
<div name="statistic" id="statistic">
<p>
<select disabled="disabled">
<option>Select Sport</option>
</select>
</p>
</div>
<% } %>
<script type="text/javascript">
Event.observe("SeasonId", "change", function() {
new Ajax.Updater('statistic', '/PlaqueOrder/GetStatistics/'
+ $F("SeasonId")) });
</script>
This will observe the season drop down and when it is changed call the PlaqueOrder controller's GetStatistics action passing the selected SeasonId to the action. The action in the controller then looks like this. I should mention that I'm using LLBLGen for the ORMapper here.
[ControllerAction]
public void GetStatistics(int id)
{
SeasonEntity season = new SeasonEntity(id);
HtmlHelper helper = new HtmlHelper(
new ViewContext(this.ControllerContext,
this.ViewData,
this.TempData));
string html = helper.RenderUserControl(
"/Views/PlaqueOrder/Statistic.ascx", season);
Response.Write(html);
}
We had to give the absolute path to the RenderUserControl because we kept getting The relative virtual path 'Statistic' is not allowed here when we used helper.RenderUserControl("Statistic"). We also had to use Response.Write to get the html created from the ViewUserControl to the browser to replace the innerHtml of the statistic div. Next is the ViewUserControl.
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="Statistic.ascx.cs"
Inherits="Web.Views.PlaqueOrder.Statistic" %>
<%= Html.Select("StatisticId",
ViewData.Sport.Statistics, "Name", "Id")%>
And here is the codebehind that types the ViewUserControl to the Season that we are passing as the ControlData.
namespace Web.Views.PlaqueOrder
{
public partial class Statistic :
System.Web.Mvc.ViewUserControl<SeasonEntity>
{ }
}
We had a hard time find much information how to do this. I'm sure there are other ways to accomplish this, but to us being able to render a ViewUserControl from a Controller is helpful with how we have used Prototype for AJAX communication.
Posted at 03:56 PM in .NET, Web/Tech | Permalink | Comments (2) | TrackBack (0)
I'm reading through Agile Web Development With Rails tonight and have come across a couple of interesting tidbits that may be good to know later.
When writing code in .rhtml files
<% 3.times do %>
Test<br />
<% end %>
will result in the following html
Test<br />
Test<br />
Test<br />
to prevent this add a minus (-) before the close of the code sections to indicate that the last line break should be ignored.
<% 3.times do -%>
Test<br />
<% end -%>
Also there is a helper method "h" that is really nice. It will parse any string into the markup required to cause the string to be rendered as it should. This eases site design and helps to protect from some hacks. So
<% h("3 < 4") %>
is translated to
3 < 3
as desired.
Also something that is worth noting is that the views have access to all instance variables in the controller that calls them, even private variables.
Posted at 12:56 AM | Permalink | Comments (0)

Recent Comments