Ask A Question

Notifications

You’re not receiving notifications from this thread.

Template Locals in Rails 7.1 Discussion

This is a great addition to Rails. It makes partials feel a lot like calling methods with required and optional arguments.

Reply

So great. I will support more your product.

Reply

Couple of nice little Easter Eggs at the end there. Love it!

One thought I had was whether the template locals can be passed into the shorthand when called render.

ie. can
<%= render @product %> handle
<%= render @products, comment_count: 2 %> or do we need to revert back to
<%= render partial: "product", product: @product, comment_count: 2 %> or even
<%= render partial: "product", locals: { product: @product, comment_count: 2 } %>

Hard to tell when reading the docs.

Sometimes I prefer to just do the long way everywhere with partial: and locals: just so I am not getting confused by the magic.

Reply

calling render... I am no longer authorised to edit my own comment WhooP!S

Reply

That should work but let me know if it doesn't!

Reply

Sorry still can't edit comments. I click edit from the comment action menu drop down and I get redirect to https://gorails.com/dashboard with a flash 'You are not authorized to perform that action'.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,256+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.