I am dealing with this more and more, it's becoming so much more popular considering the downturn in the housing market. You would have a mortgage over X% and paying rent over the remaining X%.
Come selling up time, you would get your percentage share of the profit, and so would the housing association (and so would they have veto over the acceptable selling price).
Lots of 'ins and outs' - which I can't really be bothered going into after having several drinks tonight I'd be happy to answer any questions though. I'd presume the Scottish law position would be much the same as the English law position here.