Archive for November, 2008
merb_resource_controller now supports nested (singleton) resources
November 27th, 2008 •
tags: datamapper, merb, ruby
merb_resource_controller is a merb plugin that provides the default CRUD actions for controllers and allows for easy customization of the generated actions. You might have already heard of or used one of its counterparts in rails world, like make_resourceful, James Golick’s resource_controller, Ian White’s resources_controller or other projects on github. Thx a lot for the inspiration guys!
As it so happens, today merb_resource_controller learned to work with arbitrarily nested (singleton) resources AND got a massive README update :-)
So if you are a merbivore you should really check it out and give me feedback!
What’s left to say? I say let the code do the talking …
class Articles < Application controlling :articles end
How to uninstall datamapper (or any rubygem)
November 19th, 2008 •
3 comments
tags: ruby gem datamapper
gem list dm --no-version | xargs sudo gem uninstall -a -x
gem list data --no-version | xargs sudo gem uninstall -a -x
gem list do_ --no-version | xargs sudo gem uninstall -a -x
fun with merb -i and dm-sweatshop
November 14th, 2008 •
tags: datamapper, dm-sweatshop, merb
# in spec/fixtures.rb
# of course these are just examples of what the content could look like
User.fix {{
:login => /\w+/.gen,
:password => (password = /\w{12}/.gen),
:password_confirmation => password
}}
GeoPoint.fix {{
:lat => BigDecimal.new((rand * 180 - 90).to_s),
:lng => BigDecimal.new((rand * 360 - 180).to_s),
}}
Location.fix {{
:geo_point => unique { GeoPoint.gen },
:name => /\w+/.gen,
:short_description => /\w+/.gen,
:long_description => /\w+/.gen,
:address => /\w+/.gen
}}
20.times { Location.gen }
# in config/init.rb
Merb::BootLoader.after_app_loads do
# This will get executed after your app's classes have been loaded.
if Merb.env == "development"
# allows for easy playin around in merb -i
# dm-sweatshop will provide enough data for that
require Merb.root / "spec" / "spec_fixtures"
end
end