Monday, October 23, 2006
Ruby on Rails: My ACL Needs Testing! (RUM ACL)
Hello. I have built an ACL (user-management) system with Rails and I need you to test it. Please download the zip, extract it, create your database and set it up, then run rake db:migrate.
Some pluses of this system
- Uses some AJAX features to handle trivial tasks such as adding, removing to speed up those boring tasks.
- It’s stripped down to allow for you to style it as you see fit.
- It’s very basic and easy to understand what’s going on.
Some minuses
- Uses HABTM without :through. Don’t need a full model for my relationships?
- No tests…
Could/should it be developed as a plugin? Engine?
I’d really appreciate some feedback! Send me an email: 
Download the RUM ACL: rum-1.0.zip
Labels: programming, ruby on rails
Friday, October 20, 2006
Rails, meet the Yahoo! Geocoding API
One thing’s for sure: consuming web services in Rails is not very well documented. There are a few ways of going about it, but the easiest way uses REST.
Problem: provide a way to look up a zip code to find a city. With the returned city, search the local database for a match. Then output accordingly.
Solution: Ruby on Rails with the REXML library.
Forget SOAP and XML-RPC, get REST’ed! I will show you how I went about pulling a city by zip code, then using the returned city in a query on my local database.
- Get a Yahoo! Developer Application ID.
- Open up the Yahoo! Geocoding API docs for reference.
- Use the following code in your
controller.rb
file.
# welcome_controller.rb
def city
appid = "myYahooDeveloperAppID"
url = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=#{appid}&location=90210"
@results = REXML::Document.new(Net::HTTP.get(URI(url)))
end
# views/welcome/city.rhtml
@results.root.each_element { |city| "#{city[3].text}" }
There you go. Can you believe it’s that easy?
Labels: programming, ruby on rails, yui
Thursday, October 19, 2006
All is not lost
Thankfully, I still had my old databases with all my old posts. I had to manually copy them from the old database to the new one. Didn’t take too long, and I got to relive a little of my past during it which is always neat :)
I hope to never lose my post data. It’s really cool to have a years worth of posts. I don’t have that much, but atleast there’s some of my old stale thoughts on the web.
Labels: blogging
Tuesday, October 10, 2006
Code Highlighter Plugin!
Finally! Oh, how I’ve longed for your sweet caress…
Thanks to this how-to, I was able to get syntax highlighting working. It’s super-easy to setup, however I had to do some light digging to get the proper CSS. The one I found was similar to the RubyBlue TextMate theme that I adore.
Here’s a small excerpt (for testing) of the lib/codehighlighter plugin.rb file:
require 'behavior'
require 'syntax/convertors/html'
Behavior::Base.define_tags do
tag 'code' do |tag|
lang = tag.attr['lang'] || "ruby"
convertor = Syntax::Convertors::HTML.for_syntax(lang)
code = convertor.convert(tag.expand.to_s.strip, false)
%{#{lang}-code">#{code}}
end
end And of course, the CSS:
pre.ruby-code {
background-color: #0D151E;
color: #fff;
padding: 10px 10px 10px 10px;
margin: 4px 0px;
font-size: 1.1em;
overflow: auto;
}
/* Syntax highlighting */
pre.ruby-code .normal {}
pre.ruby-code .comment { color: #428BDD; font-style: italic; }
pre.ruby-code .keyword { color: #F8BB00; }
pre.ruby-code .method { color: #077; }
pre.ruby-code .class { color: #fff; }
pre.ruby-code .module { color: #050; }
pre.ruby-code .punct { color: #FFF; }
pre.ruby-code .symbol { color: #B53B3C; }
pre.ruby-code .string { color: #1DC116; }
pre.ruby-code .char { color: #F07; }
pre.ruby-code .ident { color: #fff; }
pre.ruby-code .constant { color: #8AA6C1; }
pre.ruby-code .regex { color: #CA4344; }
pre.ruby-code .number { color: #EDDD3D; }
pre.ruby-code .attribute { color: #5bb; }
pre.ruby-code .global { color: #7FB; }
pre.ruby-code .expr { color: #227; }
pre.ruby-code .escape { color: #1C6A21; } Labels: programming
Hellow.
Now that the RadiantCMS site is back, I was able to get a copy and start using it for my site. A few months back, I did a hack in which I implemented file uploading and a meta tag manager (even though they are dead) into RadiantCMS. Many would say that I mangled the CMS, in that none of those features are really truly needed. But alas, it had to be done. Now that I’ve progressed as a Ruby developer, I hope to do some more (elegant?) hacking to fit the needs of our clients and also start doing more in-house Rails development instead of Cold Fusion which is prevalent at the time.
I’d like to look into behaviours deeper to gauge what they are capable of, and maybe create some that might come in handy.
On a side note, I believe this is the sixty-seventh time I’ve “restarted”. I hope to preserve data by export this time around.
Labels: blogging
Subscribe to Posts [Atom]