Dynamic error pages in Rails 3

In rails 3.2, it’s easier than that: Add this to config/application.rb: config.exceptions_app = self.routes That causes errors to be routed via the router. Then you just add to config/routes.rb: match “/404”, :to => “errors#not_found” I got this info from item #3 on the blog post “My five favorite hidden features in Rails 3.2” by By … Read more

What should I pass for root when inflating a layout to use for a MenuItem’s ActionView?

I would simply do it like this: menuItem.setActionView(R.layout.action_view_layout); Let Android inflate the view for you. If you need to do some extra changes on this ImageView call ImageView imageView = (ImageView) menuItem.getActionView(); Update In order to cater to your curiosity. That is what folks from Google do under the hood: public MenuItem setActionView(int resId) { … Read more

How do I extract Rails view helpers into a gem?

In my opinion, a full Engine is overkill for this task. You could instead just create a Railtie which includes your helpers into ActionView::Base when it initializes. # lib/my_gem/view_helpers.rb module MyGem module ViewHelpers def pre(text) content_tag :pre, text end def another_helper # super secret stuff end end end # lib/my_gem/railtie.rb require ‘my_gem/view_helpers’ module MyGem class … Read more