Category : ruby
Ruby – Components may not be evil, but they sure can be slow
In : ruby, Posted by admin on Mar.03, 2009
http://railsexpress.de/blog/articles/2005/11/18/components-may-not-be-evil-but-they-sure-can-be-slow Becareful when you use Ruby components. When it goes back to the controller, it may run throught some filters and slow down the application.
Articles For Scaling Ruby On Rail Web Site
In : ruby, Posted by admin on Mar.03, 2009
Here are a set of articles for RoR scaling.
- The adventures of scaling, Stage 1
- Q&A: The adventures of scaling, Stage 1
- The adventures of scaling, Stage 2
- The adventures of scaling, Stage 3
- The adventures of scaling, Stage 4
- Scaling Rails with Apache 2.2, mod_proxy_balancer and Mongrel
Very good articles.
By the way, it said:
The old codebase roughly consisted of around 50.000 lines of PHP code (plus a closed-source CMS that’s (not included in this calculation). We’ve rewritten most of it (some features were left out on purpose) in about 5.000 lines of Rails code.
Restart rails deploy in Dreamhost
In : ruby, Posted by admin on Mar.03, 2009
If you are using Dreamhost to deploy Ruby On Rails, I suggest you to look into:
Webistrano – http://labs.peritor.com/webistrano
This is a web UI to make PHP, rails deploy a lot easier. 5 stars!
Also, in case you change the source code in Dreamhost and want Dreamhost to reload the file, you see to do the following:
- SSH to your Dreamhost account
- echo “” > YOUR_DEPLOY_DIR_NAME/tmp/restart.txt
- This is trigger dreamhost’s Passenger to restart your files. Also, at the end, it will delete the tmp/restart.txt file.
ActionView::TemplateError (undefined method `logged_in?’ for #)
In : ruby, Posted by admin 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..
rubygems.rb:142:in `activate’: can’t activate rubyforge
In : ruby, Posted by admin on Jan.01, 2009
My rails app is using the old version of rubyforge.
When I start the app using ./script/server. It complains about the rubyforge as:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:142:in `activate’: can’t activate rubyforge (= 0.4.5, runtim
e), already activated rubyforge-1.0.1 (Gem::Exception)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:
in `require’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:
in `new_constants_in’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:
in `require’
from /usr/lib/ruby/1.8/soap/streamHandler.rb:62
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:
in `require’
… 65 levels…
from /usr/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/commands/server.rb:39
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from ./script/server:3
What you need to do is uninstall rubyforge and reinstall it as:
[root@pony ]# gem uninstall rubyforge
Select gem to uninstall:
1. rubyforge-0.4.4
2. rubyforge-0.4.5
3. rubyforge-1.0.0
4. rubyforge-1.0.1
5. All versions
> 5
Successfully uninstalled rubyforge-0.4.4
Successfully uninstalled rubyforge-0.4.5
Successfully uninstalled rubyforge-1.0.0You have requested to uninstall the gem:
rubyforge-1.0.1
hoe-1.5.0 depends on [rubyforge (>= 0.4.4)]
hoe-1.5.1 depends on [rubyforge (>= 0.4.4)]
hoe-1.5.3 depends on [rubyforge (>= 1.0.0)]
hoe-1.8.1 depends on [rubyforge (>= 1.0.0)]
hoe-1.8.2 depends on [rubyforge (>= 1.0.1)]
hoe-1.3.0 depends on [rubyforge (>= 0.4.4)]
hoe-1.7.0 depends on [rubyforge (>= 1.0.0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]
Successfully uninstalled rubyforge-1.0.1
[root@pony ]# gem install rubyforge
Successfully installed rubyforge-1.0.1
1 gem installed
Installing ri documentation for rubyforge-1.0.1…
Installing RDoc documentation for rubyforge-1.0.1…
undefined method `init_gettext’ for ApplicationController:Class
In : ruby, Posted by admin on Oct.10, 2008
I just updated to rails 2.1.2 and see this error:
undefined method `init_gettext’ for ApplicationController:Class
To resolve it.
- make sure you have the latest gettext gems.
- if it does not help, try add this to the first line of your app/controllers/application.rb
- require ‘gettext/rails’
Cannot do “gem install mysql”
In : ruby, Posted by admin on Jan.01, 2008
If you cannot do “gem install mysql”, it returns:
/usr/local/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… yes
checking for mysql_query() in -lmysqlclient… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Try this:
gem install mysql — \
> –with-mysql-include=/usr/include/mysql \
> –with-mysql-lib=/usr/lib/mysql