0

I have view, which render users of my app. I want to make partial, which consists necessary fields, and pass to it local variable

users/index

- @vk = VkontakteApi::Client.new
- fields = [:first_name, :last_name, :url, :photo_medium, :sex, :bdate]

- @vk.friends.get(uid: current_user.uid, fields: fields) do |friend|
  %td.span
    .centred
      = render 'shared/users', locals: { friend: friend }

shared/users

- @vk = VkontakteApi::Client.new
- fields = [:first_name, :last_name, :url, :photo_medium, :sex, :bdate]

%span= image_tag friend.photo_medium
%span= friend.uid
%span= friend.name

But if i try it there is an error

undefined local variable or method `friend'

Thanks! If you need more information, please comment about it

2
  • what line does the error reference? Commented Dec 5, 2013 at 9:53
  • = image_tag friend.photo_medium Commented Dec 5, 2013 at 9:54

1 Answer 1

3

This should work:

= render partial: 'shared/users', locals: { friend: friend }

or the shorthand:

= render 'shared/users', friend: friend
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.