render 'profile', first_name: 'Sarah'
render partial: 'profile', locals: { first_name: 'Sarah' }
Note that when you use partial
, you need to move the variables into locals
.
To check whether a variable has been assigned in a view (e.g. for optional variables):
- if local_assigns[:first_name]
# do something with `first_name`