Sharing ruby code in view layout files

Hi,

I have a block of code that is used by the layout file (html.erb) of
every view. What is the best way to include this piece of code in all
layout files?

Can I actually include a Ruby file in an html.erb file, analogous to
how files are included in PHP?

Thanks,
Amrita

There is usually only one layout file. What are you trying to do? Views can share code by using helpers. You put them in application_helper.rb.

I have a block of code that is used by the layout file (html.erb) of

every view. What is the best way to include this piece of code in all

layout files?

Can I actually include a Ruby file in an html.erb file, analogous to

how files are included in PHP?

There is no need to do a “include”, helper methods in application_helper.rb are automatically made available to all the views.

Hi,

I have a block of code that is used by the layout file (html.erb) of
every view. What is the best way to include this piece of code in all
layout files?

Can I actually include a Ruby file in an html.erb file, analogous to
how files are included in PHP?

Thanks! I gathered something was wrong with the way my application was
built. So, I shifted to a single layout file and specified the layout
in the application controller.

But its always good to know how code can be shared.

Thanks, Craig and Bala.