Archive for March, 2009

ActionView::TemplateError (undefined method `logged_in?’ for #)

In : ruby, Posted by on Mar.03, 2009

I am converting an old Ruby on Rails application to Rails 2.2.2 because the app does not work for dreamhost anymore. Dreamhost rails version is 2.2.2.

It is painful. A lot of plugin does not work. For example, I was using acts_as_authenticated plugin. However, it is no longer support. I need to convert it to restful_anthuenication plugin. The database structure is more or less the same but some of the internal stuff needs to be changed.

For example, after I add the plugin, I keep getting undefined method logged_in in the view. This is driving me crazy because I am using the logged_in method in the view to display whether the user is logged in or not. If login, I will display a logout button. If logout, I will display a login button. Since rails complain about logged_in method is not defined, I cannot display the view.

After a lot of searchs, I find it. It is n vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_system.rb:

# Inclusion hook to make #current_<%= file_name %> and #logged_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_<%= file_name %>, :logged_in?, :authorized? if base.respond_to? :helper_method
end

The key thing is that in your app/controllers/application.rb you need to add this:

include AuthenticatedSystem

oh well… move to next rail 2.2.2 migration problem..



How FriendFeed uses MySQL to store schema-less data

In : mysql, Posted by on Mar.03, 2009

Here is a posting about how FriendFeed uses MySQL to store the Json object. Then it creates separate table for each meta field to store the meta data. I use similar method to store all the static data (for example, order payment and transaction information). This method is good for data which is relatively stable.

http://bret.appspot.com/entry/how-friendfeed-uses-mysql

Tags :