-% ' (minus sign) at the end of a ERb sequence
Before Rails 3, ERB adds additional spaces before and after the value when rendering the HTML content. In HTML spaces are not significant, except when you are using special tags such as <pre>
.
Using the -
sign forced ERB to avoid additional spaces.
This is completely useless in Rails 3.
Iterating over XML with Nokogiri in ERB leaves '0' char at the end
Seems like you output the whole result of each
, while you probably want to output the iterated values:
<% @template.css('field').each do |field_node| %>
<%= raw(field_node.text) %>
<% end %>
How to create a rails checkbox form?
<% for interest in Interest.find(:all) %>
<%= check_box_tag "user[interest_ids][]", interest.id, @user.interests.include?(interest) %>
<%= interest.name %>
<% end %>
Re-ordering hash items to have some appear at the end
You can try following,
(hash.keys - end_keys + end_keys).map { |key| [key, hash[key]] }.to_h
Python range() with negative strides
You can specify the stride (including a negative stride) as the third argument, so
range(10,-11,-1)
gives
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]
In general, it doesn't cost anything to try. You can simply type this into the interpreter and see what it does.
This is all documented here as:
range(start, stop[, step])
but mostly I'd like to encourage you to play around and see what happens. As you can see, your intuition was spot on.
Related Topics
How to Get the Target of a Symlink
How to Switch to an Older Version of Rails
Homebrew Install: Failed During: Git Fetch Origin Master:Refs/Remotes/Origin/Master -N --Depth=1
Transforming Datetime into Month, Day and Year
Aws Elastic Beanstalk - How to Upgrade Existing Environment from Ruby 2.1 to Ruby 2.2
How Mix in Routes in Sinatra for a Better Structure
How to Use "Puts" to the Console Without a Line Break in Ruby on Rails
Embedding JSON Data into Yaml File
Finding the Session Id in Rails 3
What Is '$:.Unshift File.Dirname(_File_)' Doing
What Does Post.All.Map(&:Id) Mean
Iterating Between Two Datetimes, with a One Hour Step
Stack Level Too Deep Error in Ruby on Rails
Why Are My Bigdecimal Objects Initialized with Unexpected Rounding Errors
How to Deal with Not Knowing What Exceptions Can Be Raised by a Library Method in Ruby