How do I do multiple lines of Ruby in html.erb file?

It's really wired to define a method in ERB file and really don't advice If you want call a block like #each you can do : % names. Each do |name| %.

It's really wired to define a method in ERB file and really don't advice. If you want call a block like #each you can do : You forget the end.

And you forgot a | after |name ;-) – jigfox Jun 23 '10 at 8:18.

If you need extra functions in your view, you normally declare those inside a helper. For each controller, if there is a helper it is automatically loaded. For instance, if you have a PeopleController, in the app/helpers folder, there should be a people_helper.

Rb, and it should look like this module PeopleHelper def name #do something username end end Another, very clean alternative, is to use the Presenter pattern, but I think it is less common (unfortunately). Otherwise, if you do need multiple lines of ruby code inside a erb view, which I try to avoid, I prefer the following style: Also for me code indentation is more important than html indentation, so I will prefer something like But I am always very interested to hear different opinions in this matter.

1 Helper methods are the way to go, for sure. – tadman Jun 23 '10 at 14:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions