# Importing assets into the application layout (Asset Tags) <%= stylesheet_link_tag "your_stylesheet" %> <%= javascript_include_tag "your_javascript" %> <%= image_tag "happy_cat.jpg" %> <%# comment %> ? <%= link_to "Sample Text", whichever_path %> # With clas <%= link_to "Sample Text", whichever_path, class: "my-btn" %> # Passing params link_to "Edit this post", edit_post_path(3) # don't hardcode 3! # Or specify more params post_path(3, :referral_link => "/some/path/or/something") # Rendering partials <%= render "user_form" %> # this will be from a file called _user_form.html.erb in app/views/users # Passing variables to partials (using the locals "options hash") <%= render partial: "shared/your_partial", :locals => { :user => user } %> # Or <%= render "shared/your_partial", :user => user %> # If the partial name + the variable name are the same, use this shorthand notation <%= render user %> # To change the action of a Turbo Drive link, you can use data attributes inside of your Rails link tags <%= link_tpo "Edit Post", edit_post_path(@post), data: { turbo_action: "replace" } %> # This will => <a href="..." data-turbo-action="replace">Edit Article</a> # Change the HTTP Request Method of a Turbo link <%= link_to "Delete Post", post_pat(@post), data: { turbo_method: "delete" } %> # This will => <a href="..." data-turbo-method="delete">Delete Article</a> # Disable Turbo Drive <div data-turbo="false"> # Disabled <%= link_to "foo", "bar" %> # Disabled <%= link_to "baz", "qux", data: { turbo: "true" } %> # Enabled </div>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter