I’m a Ruby noobie, I admit it. Coming from a .NET background, Ruby has been a learning experience for sure, but I certainly feel lke I’ve learned something along the way. One aspect of the Rails framework I really like is the relaxed attitude to working with the database – I really rarely have to worry about it.
That said, I’ve been puzzling over the use of inheritance with Active Record. In .NET land and with NHibernate, I’d quite happily have this:
class AbstractUser
class AdminUser : AbstractUser
class StandardUser : AbstractUser
All the *User subtypes have their own extra properties, and the AbstractUser provides some common ones like email, password, username.
Ruby doesn’t actually provide for abstract classes, so that’s one issue. But another issue is the way in which ActiveRecord deals with inheritance. Only single table inheritance is supported via the user of a discriminator column. My issue with this is that there’s no good way to support extra properties on a subclass – the properties would have to be added to the Users table and therefore without some trickery would be available to all User subtypes.
One possible solution for this is as follows:
class AbstractUser < ActiveRecord::Base
end
class AdminUser < AbstractUser
has_one :admin_details
end
In this case, we have another model - and therefore another table - which provides the AdminUser's extra properties. This can then be used as follows:
admin = AdminUser.new
admin.admin_details.direct_line = '+44 567 7890'
This works fine, the values are off in a separate table and everything's separated out as I'd like. But the syntax is clunky. I don't really want to have to do admin.admin_details.direct_line, I want to do admin.direct_line. So I wrote a little extra method to do this:
class AdminUser < AbstractUser
incorporates :admin_details
end
All this does is set up a has_one as normal, but then provide extra methods for getting and setting all of the attributes of admin_details, meaning that admin.direct_line will work as expected. The code for incorporates has_one is up on github now - it's the minimum that was required to get this to work, so please feel free to fork it. I do wonder if I'm missing something that's already built into Rails, but if I am, it's damn hard to find.
This approach makes me pretty happy overall - in the scenario I've got right now, I never actually need a base User, which is why I'm referring to it as AbstractUser, and it would really be better if that could never be instantiated. But it's a minor niggle, and the whole setup plays well with Rails' polymorphic routing and suchlike, and works with Authlogic too. I can already see some improvements, so I hope someone forks the gist and I can learn something from Rubyists!
Getting IIS 7.5 (in VirtualBox and VMWare) to Serve Sites from an OSX Share
September 24th 2009, 9:57 am in IIS, OSX, VMWare Fusion, virtualbox.
A longwinded title, but this is mostly as a note for me. Assuming your Mac’s IP address is 192.168.1.101:
- You need matching users with matching passwords on both Windows and OSX. So, your main user on OSX is u:colin/p:password. You need a user on Windows u:colin/p:password. Casing is important!
- Enable SMB on OSX from File Sharing
- Share the OSX folder you want to serve up (let’s say it’s named “mysite”)
- Create a new site in IIS with the physical path as \\192.168.0.101\mysite
The first point is key, as is using the UNC path in the last point, rather than a mapped drive. I used this Stack Overflow question to get this up and running.
Update: I just tried to run some unit tests via the Resharper test runner and received a security exception. The following fixed the issue:
caspol -m -ag 1 -url “file://\\192.168.0.101\mysite\*” FullTrust -exclusive on
This post from backroom security tech and also this from .NET security blog helped here.
Update 2: In a new VMWare VM, I came across two additional problems. Using ” around the URL caused caspol to throw an error, and having spaces in the URL doesn’t work – replace them with %20.
Update 3: In some cases, such as writing across the UNC share to the virtual directory your site is running in, you may need to set up Impersonation in the web.config with your matching user. You may additionally need to set the AppPool identity to that shared user. Note that I now have this system working in VMWare Fusion.
I’m really excited that the final release of Ext JS 3/ is here, along with a preview of the Ext JS Designer application. This is built on top of Adobe AIR and allows developers to piece together their Ext JS app with a rich UI, tweaking configuration options and embedding components as required.
To my knowledge, there is no other JavaScript framework approaching the richness of Ext JS, and this designer takes it to the next level. I’m extremely excited about what the brilliant Ext JS team has in store for the future.
Start off by creating a fresh new drive of the size you’re after using the VirtualBox user interface. Then, locate both the your old, smaller HD and the new, larger one and run the following command:
VBoxManage clonehd --existing oldhd.vdi newhd.vdi
After some progress indicators ahve come and gone your HD should have been cloned to the larger one. You now need to use some software to expand your drive partition into the new space. Vista and W7 have this feature built in to Disk Management, or you could use something like GParted.
After yesterday’s post I didn’t really imagine that it’d attract the attention of anyone in the right departments – I guess I just assumed the problem would get fixed due to someone high up noticing it. What I didn’t imagine is that the problem would get replaced by another totally different issue:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Cannot create an object of type 'System.Web.UI.WebControls.Unit' from its string representation 'r_height' for the 'Height' property.
Source Error:
Line 1559: <div class="sys_news">
Line 1560: <div class="sys_standardrepeater">
Line 1561: <asp:literal visible="false" id="D2_Count" runat="server" text="0" /> <contensis_controls:dataviewdatalist id="D2" runat="server" repeatlayout="Flow" cssclass="sys_standardRepeater" height="r_height" repeatdirection="Vertical" repeatcolumns="1" shuffledataset="False" displaytype="SpanLayout" onupdatecommand="dlUpdateCommand" oncancelcommand="dlCancelCommand" oneditcommand="dlEditCommand" ondeletecommand="dlDeleteCommand" onitemcommand="Link_Data_Click" datakeyfield="PageID"><itemtemplate><% D2_Count.Text=cstr(clng(D2_Count.Text)+1) %>
Line 1562: <h2 class="sys_repeaterItemInner">
Line 1563: <%# CustomProcessing_D2(DataBinder.Eval(Container.DataItem,"newsHeading"),"newsHeading") %>
What sort of process is in place to allow a developer to replace a known failing page with another failing page? Surely, knowing that the first version was failing you’d be double-eager to check the latest upload is working? Baffling.
My local council, Gateshead in the UK, recently had a notice on their website declaring that it would not be updated for two weeks as they were performing essential maintenance. This was WTF number one – I have no idea what happened behind the scenes to make them buy this nonsense but it smacked to me of technical incompetence. What do I know though – like I say, there could have been valid reasons for this decision and it’s really not that big a deal.
So today I went back on their website and it seemed to be up and running with some new updates. I hit the News section to see this message:
Server Error in '/' Application.
Compiler Error Message: BC30569: 'New' cannot be used on a class that is declared 'MustInherit'.
Source Error:
Line 341: DataviewObject(component).GetData
Line 342:
Line 343: Dim RSSWriter As New CMS_API.WebUI.WebControls.BaseRSSFeedWriter
Line 344:
Line 345: Me.Controls.Add(RSSWriter)
Source File: E:\websites\www.gateshead.gov.uk\Council and Democracy\news\home.aspx Line: 343
Ouch. This brought down the page with a bang, no decent error handling. What’s the problem? It looks like someone’s been trying to set up the RSS feed for that page but has used an abstract class instead of the concrete one. Fair enough, that’s a simple mistake but surely WTF number two is that this could be pushed to a production server?
A good provider would have a local test, a staging server, and then production, at the very least. It looks to me like this change has been pushed directly to the site without any kind of quality control.
A possible WTF number three arises when you think again about the error message in general, which should only be shown when debug information is available. This could mean that debug settings are enabled on the web server, which is a definite WTF. Showing any kind of information like this – such as drive names and file paths – probably isn’t a very good idea.
I wouldn’t really care if this was just some corporate website but I know that my tax has gone into the development of this system and it’s painfully clear that the developers are not up to the job. Are open bidding systems in place for this kind of contract? I don’t know, but I bet that even if they are they don’t go on merit. Gateshead Council: shame on you. Can I get a refund? I can certainly recommend so decent software companies with local ties:
Learning Ext JS is Up For the Packt Author of the Year Award
May 5th 2009, 5:50 pm in Ext, Personal.
The book which Cutter, Shea and I wrote is up on the publisher’s site for the Author of the Year award. Obviously in our case it’d be co-author of the year but it’d be really nice to be in with a chance. Packt have a microsite for the award and the actual poll is here. It’s up against some other great books so if you could spare a minute to vote it would certainly be appreciated!
The Ext JS 3.0 examples are online already, and I believe Jack made the announcement at the Ext Convention today. Take a look at this sample showing how to create a Microsoft Word-style ribbon UI with Ext JS 3.0. I really like the new button features and the GroupTabs. I’d expect some more examples on how to use some of the new features like the charting and Ext.direct and I’ll try and cover those when they appear.
Update: Cutter points out that there’s a new Image Organizer which shows off the Direct functionality but I can only see that in the download at the moment. The examples on the download also cover charting too.
After I wrote Fizzler in a burst of development enthusiasm a few months back, it’s been sat on Google Code – a solution in need of a problem to solve. That is until Colin Eberhardt emailed me to report a bug in the selector engine, and to talk a bit about the way he was using Fizzler when working with WPF. This was totally outside the domain I’d anticipated Fizzler being use in, and Colin E has now revealed his project in full. By wrapping part of Fizzler in a few interfaces, thus abstracting it away from HTML and towards a more general purpose solution, he was able to use it to query a XAML UI definition and apply style declarations. CSS selectors for WPF!
This is an amazing use case for a library which I hope will start to see more use in the future. Thanks to Colin E for letting me know about the work which Scottlogic are doing with Fizzler.
I love the idea of Balsamiq Mockups; it’s one of those idea which makes you wonder why it took someone so long to come up with it. Knock together a few UI mockups from common UI elements and you’ve got a great way to preview sites and programs to your client.
In fact I’ve seen people use the Visual Studio win/web forms drag and drop for this sort of thing but it’s pretty limited in terms of the UI elements you can use and the amount of information you can present without doing some coding work. When Balsamiq Mockups lets you put a data table on the page, for example, you can do headers, links and data with a simple comma separated list. It lets you display a placeholder for a mapping interface with absolutely no code.
So the idea and the basic implementation are both great, but I’m not sold on the larger picture. If you’re trying to explore a UI then you’re going to need more than one screen. It looks like Balsamiq Mockups supports this on the desktop version by letting you save mockups and load them later, but I’d really like to see a way of having multiple mockups together in one canvas. I think there’s a case for saying that this increases the complexity of BM in that many would like to see a way of showing how each mockup links to the next. I’m not too bothered about that, I’d just like to see multiple “pages”, each presenting a different mockup.
The other thing that baffles me is the ability to get an online preview of BM but not being able to use the software online once you’ve bought it. I’d really love to see an edition where I can use the software online, save my mockups in my online account, and be able to access them from anywhere. I’m writing this from my netbook and it’d be great to look at the mockups I’d created on my desktop without having to pass the files over.
I don’t want these points to distract from Balsamiq Mockups though, because it’s great, a revelation in fact. The way it allows us to piece together UI ideas without resorting to pen and paper or a paint package is a dream come true and gives us another method of rapidly prototyping for our end users.