Archive for the 'ruby & rails' Category

Models in Rails Plugins

Having models in Rails plugins is a bad idea. If you need the model for your plugin - make a generator. Or extend AR::Base with class method that will extend user model to give it desired functionality.

Site5 offers Rails hosting

Well, basically that’s all they do.
They have ruby, rubygems and a few gems installed. Also they have a control panel for managing ruby stuff. Have RubyGems manager. But it’s unable to list installed gems, unable to install gems. It’s completely broken. You have to hack a lot in terminal to have an opportunity to install and use other gems.
Next, they have a section for managing rails apps. It can create a new rails app. And… And that’s all. It can not even start that app. It doesn’t generates deploy config. It’s just useless.
BTW, they don’t even think about running mongrels/thins/ebbs/whatever. They are thinking about a single instance on fastcgi.
Next, support. They’re very polite but ignorant. “Is your computer turned on?”. As a solutions they give links to forums where users write “guides” and nothing from site5 itself.

Conclusion: get a slice for same money instead. You’ll be pleased.
BTW, with any VPS you’ll get an opportunity to run not only Rails apps but virtually anything. Like Merb apps.

“the results … are undefined”

Kill anybody who’ll write that in spec.

Specification: An explicit set of requirements to be satisfied by a material, product, or service.

I was reading ruby-core mailing list when I stumbled this message about
Improving the metaprogramming facilities of Ruby. It proposes to introduce some changes to Ruby spec regarding instance variables access. The problem is that almost any of proposed changes ends with the silly “the results … are undefined”. Even currently there’s no complete spec for Ruby. The only MRI is a “golden implementation” but still not fully documented and it still has its bugs. Thanks to guys from Ruby-Spec project for their effort on creating complete spec suit to ensure that all alternative implementations are compatible. Anyway, how implementations can be compatible if their behavior is undefined in some cases?

Side note: W3C should also eliminate any undefined behavior for implementations.

NDIA: application configs in repository

Never put application configs in repository. Put there config examples with a explanations in comments instead. That will help users to configure the application better then rewriting teir config on each update.

PS: NDIA - Newer Do It Again

Rails power. Use with caution.

I’ve found a few lines of code that make use of Rails’ method returning. I’ve seen it on the Errtheblog before and thought that it can be useful but someone will misuse it for sure. So here it is.

def feeds_list returning([]) do |feeds| BLOGS.each do |blog| feeds < < feed_url_for(@app_name, blog) end end end

Why do people do such things if there’s Array#collect

def feeds_list BLOGS.collect do |blog| feed_url_for(@app_name, blog) end end

Status update

Визитка

Цитата дня

About Specs

Условная инициализация

a ||= [] if (!isset($a)) $a = array();

Как по мне, так руби гораздо более приятней. :)

dispatch.fcgi

Если вы взяли чужой ror-проект и он усердно выдает содержимое dispatch.fcgi - посмотрите на ваш сервер. Возможно, у вас установлен не mod_fastcgi, а mod_fcgid. В таком случае добавьте в public/.htaccess следующую строчку:

AddHandler fcgid-script .fcgi

Также проверьте, уставлены ли права на выполнение у dispatch.fcgi.