Undefined local variables in Rails 3 partials after upgrade to Ruby 1.9.3 -
i know there several posts on issue none of solutions i've read here.
i've upgraded ruby 1.8.7 1.9.3p429 , now, undefined local variable in partials.
i calling partial (from partial in case that's relevant) thusly:
= render :partial => 'user_name', :locals => {:user => item_user, :extra_class => "active"}
in partial, access these locals thusly:
- if(current_user , user.silhouette_user_id.to_i == current_user.silhouette_user_id) = notranslate(current_user.full_name) - else - if !local_assigns[:extra_class].nil? = notranslate(link_to( h(user.full_name), stream_url(:user_id => user.silhouette_user_id), :class => extra_class )) rescue "anonymous" - else = notranslate(link_to( h(user.full_name), stream_url(:user_id => user.silhouette_user_id) )) rescue "anonymous" = notranslate(link_to "pro", "#", :class => "badge badge-pro", :title => "#{user.part_name} pro") if sso.is_pro? user
i can access locals via local_assigns hash, if add these lines top, have access:
- user = local_assigns[:user]
- extra_class = local_assigns[:extra_class]
i live that. however, gets worse. user activerecord model object. cannot, however, access attributes of object user.attribute notation. instead have user user[:attribute].
i still except of attributes of user methods, cannot access using user[:method].
i thought might rails, @ 3.1.12 upgraded 3.2.13 no change.
any ideas? haml processor? other posts solved used erb.
try using way rendering partials (it's correct way rails 3):
= render 'user_name', user: item_user, extra_class: "active"
and access objects using user
, extra_class
Comments
Post a Comment