This project is archived and is in readonly mode.
Helper methods naming collision
-
Rafael Mendonça França
I could reproduce this issue in rails 3.0.0.
module AHelper def foo 'A' end end module BHelper def foo 'B' end end class AController < ... def index render :inline => '<%= foo %>' end class BController < ... def index render :inline => '<%= foo %>' end end /a => 'B' /b => 'B'If I create the helper using block help in controller the rails render the currect letter, like this
class AController < ... helper { def foo; 'A'; end } def index render :inline => '<%= foo %>' end class BController < ... helper { def foo; 'B'; end } def index render :inline => '<%= foo %>' end end /a => 'A' /b => 'B' -
Rafael Mendonça França
In rails master this works fine.
I attached a patch with failing test in 3-0-stable branch.
-
David Trasbo
Rafael,
This does not work on
mastereither:$ script/rails g controller a index $ script/rails g controller b indexroutes.rb:Ticket5565::Application.routes.draw do resources :a resources :b endHelpers:
module AHelper def foo 'A' end end module BHelper def foo 'B' end endIn both views:
<%= foo %>http://localhost:3000/a=> "B"http://localhost:3000/b=> "B" -
Rohit Arondekar
- State changed from new to invalid
- Importance changed from to Low
You need to do clear_helpers in the conflicting controller like so:
class AsController < ApplicationController clear_helpers . . . endThis will remove all existing helpers except the ones defined for that class. In the above case AsHelper
Related ticket: #5348 Visibility of helpers seems all wrong
