I just released Merb Multisite demo app. You can setup your domains or subdomains and have each site with you own views located in /sites/[site_path]/ and an asset helper to get images from /public/sites/[site_path].
For more info:
Merb Multisite source.
Special thanks to Matthijs Langenberg for sharing his code.
Have fun!
Twitter doesn't like me
Posted by Peter
on Mar 04, 09
Why I can't login to twitter just when I want to use it?

I think their testing suite is not very strict!
I can try later it's not important.

I think their testing suite is not very strict!
I can try later it's not important.
Merb Custom Exceptions
Posted by Peter
on Nov 21, 08
Adding your own custom exceptions in Merb is pretty easy and I'm adding this post basically for those lazy ones that search or ask before reading the documentations including myself.
In the source code docs is well explained you can extend any of the HTTPError classes and add the required action to your Exceptions controller, say:
Create a custom view in app/view/exceptions/user_not_found.html.erb
And I extended in my own User model at the bottom:
or you could just extend Exception and define the HTTP error status in your method in exceptions controller.
Now you can start raising sweet exceptions:
In the source code docs is well explained you can extend any of the HTTPError classes and add the required action to your Exceptions controller, say:
class Exceptions < Merb::Controller
def user_not_found
render :format => :html
end
end
Create a custom view in app/view/exceptions/user_not_found.html.erb
And I extended in my own User model at the bottom:
class UserNotFound < Merb::ControllerExceptions::NotFound
end
or you could just extend Exception and define the HTTP error status in your method in exceptions controller.
Now you can start raising sweet exceptions:
raise UserNotFound unless @user
Adding color to your Merb.logger
Posted by Peter
on Oct 31, 08
Thanks to teamon you can add life to your Merb.logger by simple adding this patch in lib/color_logger.rb
and load it in file config/environments/development.rb using
and load it in file config/environments/development.rb using
Merb.push_path(:lib, Merb.root / "lib")
[BUG] cross-thread violation on rb_gc()
Posted by Peter
on Oct 15, 08
I was having this weird issue for sometime when starting Merb in a frozen app and I was even using ruby 1.8.6:
Google didn't help me, then I remember about the new 'thor merb:gems:redeploy' task that recompile gems on the target platform and gave it a shot, resulting:
Building native extensions. This could take a while...
Successfully installed do_mysql-0.9.6
Building native extensions. This could take a while...
Successfully installed fastthread-1.0.1
Building native extensions. This could take a while...
Successfully installed hpricot-0.6.161
Building native extensions. This could take a while...
Successfully installed mongrel-1.1.5
Fastthread was probably compiled with the original OSX Ruby 1.8.2 resulting in this [BUG]!?
Awesome, I have my merb app working again in my dev box. Now updating it to work with Merb RC1 and new merb-auth.
Thanks thor!
Peter.
[BUG] cross-thread violation on rb_gc()
ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
Abort trap
Google didn't help me, then I remember about the new 'thor merb:gems:redeploy' task that recompile gems on the target platform and gave it a shot, resulting:
Building native extensions. This could take a while...
Successfully installed do_mysql-0.9.6
Building native extensions. This could take a while...
Successfully installed fastthread-1.0.1
Building native extensions. This could take a while...
Successfully installed hpricot-0.6.161
Building native extensions. This could take a while...
Successfully installed mongrel-1.1.5
Fastthread was probably compiled with the original OSX Ruby 1.8.2 resulting in this [BUG]!?
Awesome, I have my merb app working again in my dev box. Now updating it to work with Merb RC1 and new merb-auth.
Thanks thor!
Peter.
MerbCamp - October 11-12th
Posted by Peter
on Sep 10, 08
Great time for Merb community, MerbCamp is coming to San Diego and registration is open: merbcamp.com.
Git clone Feather and use edge branch
Posted by Peter
on Jul 22, 08
git clone git://github.com/mleung/feather.git
git branch -a
List all local and remote branches
git checkout -b edge origin/edge
Creates a new local 'edge' branch from the cloned 'edge' branch
This also sets up things so that pull and merge work correctly
You are on Feather edge
git checkout master
Returns to master branch
git branch -a
List all local and remote branches
git checkout -b edge origin/edge
Creates a new local 'edge' branch from the cloned 'edge' branch
This also sets up things so that pull and merge work correctly
You are on Feather edge
git checkout master
Returns to master branch
Datamapper Timestamps
Posted by Peter
on Jul 18, 08
If you want your created_at, updated_at, created_on and updated_on fields automatically set in your Datamapper model, you need to require 'dm-timestamps' before.
require 'dm-timestamps'
class Asset
include DataMapper::Resource
property :id, Integer, :serial => true
property :created_at, DateTime
property :updated_at, DateTime
end
Releasing Feather Pages plugin
Posted by Peter
on Jun 08, 08
It was very fun to learn more about Feather internal hooks and how to create a plugin. I found very interesting how it can interact with the base blog engine and with other plugins letting you register a partial to a specific view hook point, for example the Pages plugin list all pages and sub pages in the sidebar and each one display your meta description and keywords in the header for better SEO.
Your query failed 'MySQL server has gone' away
Posted by Peter
on May 31, 08
My blog was getting an error every once in a while, probably if no connection was made in 8 hours.
This happens because neither AR and Datamapper close their connections letting the database to take care of it, so I tried to change MySQL setting to:
wait_timeout = 259200
but this won't help me much so I will try some hacking tonite and update this post again.
This happens because neither AR and Datamapper close their connections letting the database to take care of it, so I tried to change MySQL setting to:
wait_timeout = 259200
but this won't help me much so I will try some hacking tonite and update this post again.