Search code examples
ruby-on-railsslim-lang

Rails|Slim : Assign new local variables in view


I have a local variable in a view @people, it is possible to assign an association of the local variable to another one.

-@people.interactions = @interactions

I tried this but it did not work, is there a way to accomplish the same?


Solution

  • Try this:

    - interactions = @people.interactions
    = interactions
    

    The slim so you can assign a value to a variable:

    - my_text = my_value
    

    And so their output:

    p
      = my_text