Gitorious running over Rails 2.2.2

9 views
Skip to first unread message

AkitaOnRails

unread,
Jan 7, 2009, 1:47:29 PM1/7/09
to Gitorious
Hello

If you're watching the newest updates to the main repo, you'll see
that I've been quite busy :-)

I've been tweaking the code since yesterday to update everything to
run over Rails 2.2.2. My goal was to have i18n and start a
localization process. As I am from Brazil, this is important for me
and I think it would benefit people from other countries as well.

Fortunatelly the code is well covered by test, which made my job
easier. But there are still some oddities that I would like to expose
here. One is actually breaking my head right now.

Take this route:

map.resources :projects do |projects|
projects.resources :repositories, :member => { :new => :get }
end

This is a simplification of the clone page. If I load this under Rails
2.1.0 and simulate his named route:

>> new_project_repository_path(1,2)

It works properly and gives back:

=> "/projects/1/repositories/2/new"

But, if I just change the version to Rails 2.2.2 and run it again, now
I have:

>> new_project_repository_path(1,2)
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym
from /opt/ruby-enterprise-1.8.6-20081205/lib/ruby/gems/1.8/gems/
actionpack-2.2.2/lib/action_controller/routing/route.rb:243:in
`extra_keys'
from /opt/ruby-enterprise-1.8.6-20081205/lib/ruby/gems/1.8/gems/
actionpack-2.2.2/lib/action_controller/routing/route.rb:243:in `map'
from /opt/ruby-enterprise-1.8.6-20081205/lib/ruby/gems/1.8/gems/
actionpack-2.2.2/lib/action_controller/routing/route.rb:243:in
`extra_keys'
from generated code (/opt/ruby-enterprise-1.8.6-20081205/lib/ruby/
gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route.rb:
154):3:in `generate'
from /opt/ruby-enterprise-1.8.6-20081205/lib/ruby/gems/1.8/gems/
actionpack-2.2.2/lib/action_controller/routing/route_set.rb:339:in
`generate'
from /opt/ruby-enterprise-1.8.6-20081205/lib/ruby/gems/1.8/gems/
actionpack-2.2.2/lib/action_controller/url_rewriter.rb:149:in
`url_for'
from (eval):18:in `new_project_repository_path'
from (irb):2

Does anyone know what have changed in the nesting logic of 2.2.2 that
makes this break to badly?

For the time being I had to left a canonical hash with
explicit :controller, :action keys so it wouldn't blow, but it would
be nice to have it back to the named route.

Johan Sørensen

unread,
Jan 8, 2009, 3:38:23 AM1/8/09
to gito...@googlegroups.com
Hi,

On Wed, Jan 7, 2009 at 7:47 PM, AkitaOnRails <fabio...@gmail.com> wrote:
> If you're watching the newest updates to the main repo, you'll see
> that I've been quite busy :-)

Very nice, thanks for the work.

> But there are still some oddities that I would like to expose
> here. One is actually breaking my head right now.
>
> Take this route:
>
> map.resources :projects do |projects|
> projects.resources :repositories, :member => { :new => :get }
> end
>
> This is a simplification of the clone page. If I load this under Rails
> 2.1.0 and simulate his named route:
>
>>> new_project_repository_path(1,2)
>
> It works properly and gives back:
>
> => "/projects/1/repositories/2/new"
>
> But, if I just change the version to Rails 2.2.2 and run it again, now
> I have:
>
>>> new_project_repository_path(1,2)
> NoMethodError: You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.to_sym>

> [snip]


> Does anyone know what have changed in the nesting logic of 2.2.2 that
> makes this break to badly?

I think the primary reason is probably that we're breaking rails
conventions horribly here, basically the #new and #create actions in
the RepositoriesController behave very differently in that they
require the repository id as well in the route
(/projects/x/repos/y/new as opposed to the usual rails way:
/projects/x/repos/new). I've forgotting my originally reasoning for
breaking that convention, but probably related to being too lazy to
figure out two better action names, or move it to another controller.
Any suggestions for a nicer approach? The intent of the to actions is
to clone a repository.

JS

AkitaOnRails

unread,
Jan 8, 2009, 7:35:17 AM1/8/09
to Gitorious
As we are already using :member => { :new => :get }, what about
actually having a 'clone' action and change it to :member => { :clone
=> :get } ?

On Jan 8, 6:38 am, "Johan Sørensen" <jo...@johansorensen.com> wrote:
> Hi,
>

Johan Sørensen

unread,
Jan 12, 2009, 5:10:05 AM1/12/09
to gito...@googlegroups.com
On Thu, Jan 8, 2009 at 1:35 PM, AkitaOnRails <fabio...@gmail.com> wrote:
>
> As we are already using :member => { :new => :get }, what about
> actually having a 'clone' action and change it to :member => { :clone
> => :get } ?

Yup:

commit 342f7b727c5aadb796fff6ac5f7dedf4647e1a1c
Author: Johan Sørensen <jo...@johansorensen.com>
Date: Mon Jan 12 11:05:28 2009 +0100

rename RepositoryController#new/create to #clone/#create_clone to
avoid future
confusion and rails issues. Update AUTHORS as well.


JS

AkitaOnRails

unread,
Jan 12, 2009, 10:03:02 PM1/12/09
to Gitorious
Awesome, this should work. And it is great to see people actually
using it. I stumbled upon the same bug in Rails 2.2.2's truncate
method need of the :omission key.
http://gitorious.org/projects/gitorious/repos/billms-clone/commits/4b8fea05e3e3e72b2a1503a23f8880907208e05e
I was going to submit it but billm did it first.

Did anyone try to benchmark the pre-Rails 2.2.2 agains the current
version? It would be interesting to know if 2.2.2 gives in any free
improvements to performance.

And speaking about performance, I see that there are various fragment
caching in place. Did someone measure to see if there is any other
bottlenecks we can attack?

On Jan 12, 8:10 am, "Johan Sørensen" <jo...@johansorensen.com> wrote:

Bill Marquette

unread,
Jan 12, 2009, 11:22:36 PM1/12/09
to Gitorious
On Jan 12, 9:03 pm, AkitaOnRails <fabioak...@gmail.com> wrote:
> Awesome, this should work. And it is great to see people actually
> using it. I stumbled upon the same bug in Rails 2.2.2's truncate
> method need of the :omission key.http://gitorious.org/projects/gitorious/repos/billms-clone/commits/4b...
> I was going to submit it but billm did it first.

I'm running into another odd one (well a couple, but I'll start with
this one). The OpenID plugin throws some nasty exceptions:
A NoMethodError occurred in sessions#create:

undefined method `relative_url_root' for
#<ActionController::CgiRequest:0x2c10fe9c>
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/
cgi_process.rb:111:in `method_missing'

This commit seems to fix it:
http://github.com/rails/open_id_authentication/commit/00d8bc7f97b9a3113e004475b63dbf84f5397237

but that's for 2.1 backwards compatibility based on the commit log.
Applying the patch to my local copy fixes it, not sure if it was an
issue prior to the update to 2.2.2.

I had to do unholy things to the exception notifier to have it
actually mail me - changing environments/production.rb seemed to make
zero difference (still used the default.com sender address with no
recipient) - I never did track it down, I noticed it while trying to
figure out the truncate issue.

--Bill
Reply all
Reply to author
Forward
0 new messages