문제

I'm trying to create an admin partial that has all the utility addons I need for my website in one file to reduce clutter, using a local I should be able to tell what part I need based of the string that I pass as a local.

= render 'admin/projects', locals: { utility: "delete" }

and in my _projects

- if request.subdomain == 'admin'
  -if :utility == "delete"
    %button.delete

When run no button appears, if set to != 'delete' a button appears.

Why isn't my variable being set?

도움이 되었습니까?

해결책

You're comparing a string to a symbol, you probably want to write:

- if request.subdomain == 'admin'
  -if utility == "delete"
    %button.delete

Your render syntax is also a bit off, instead of:

= render 'admin/projects', locals: { utility: "delete" }

Use

= render :partial => 'admin/projects', locals: { utility: "delete" }

I answered a similar question earlier here: Rails asking for a secret key to create model

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top