Possible Duplicate:
In Ruby, what are the vertical lines?
This question seems Google-proof, and I do not know Ruby.
Comparing different presence of |f| at the end of a line in a model description causes content not to be shown. I am just trying to fix a bug in a page that does not provide access to some information in a table.
“What does ||= do in Ruby” about the || does not seem to help.
Here is the suspect code from the broken .rb file:
comma :show_mytable do |f|
table2 :field2
table3 :field3
end
but this seems to work, showing the desired fields when activated:
comma :show_mytable do
table2 :field2
table3 :field3
end
Could |f| prevent output from showing?
In your code, you are passing two variables to the
commamethod. The first is a symbol called:show_mytableand the second is a block. It is unrelated to the ||= syntax which is conditional assignment.Here is an example of how blocks are used in ruby:
When you use a loop(
eachin this case), you can pass it a variable(element) to give you a way to reference the current element in the loop.You can also use curly braces instead of
doandendlike this:Since you aren’t looping through anything here I don’t see any reason you could need the
|f|in your example.