From: Rohit Coder Date: 2013-05-28T02:57:05+09:00 Subject: How to show menu in application.html.erb on other pages? --_f337f452-dac6-4314-9581-64708d70164f_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =0A= I am using Aptana Studio 3 to write a small application. =0A= =0A= In the Views folder=2C I added a new .html.erb page and added a jQuery =0A= navigation menu bar. This page also has a banner. I want to keep this as=0A= a base page (like Master Page in .NET) for all the other pages. =0A= =0A= I want all the other pages to automatically show the banner and menu bar on= top. =0A= =0A= How to do this? I am using Rails 3.2. =0A= =0A= =0A= =0A= Code of application.html.erb: =0A= =0A= =0A= =0A= =0A= =0A= <%=3D stylesheet_link_tag "application"=2C :media =3D> "all" %>=0A= <%=3D javascript_include_tag "application" %>=0A= <%=3D csrf_meta_tags %>=0A= =0A= =0A= =0A= =0A= =0A= <%=3D yield %>=0A= =0A=
=0A=
=0A= =0A=
=0A=
=0A= =0A=
=0A=
=0A= =0A=
<%=3D content_for?(:content) ? yield(:content) : yield = %>
=0A= =0A= =0A= =0A= Code of Content.html.erb =0A= =0A= =0A= <% content_for :content do %>=0A=
=0A= <%=3D content_for?(:news_content) ? yield(:news_content) : yield = %>=0A= <% end %>=0A= <%=3D render :template =3D> 'layouts/application' %>=0A= =0A= =0A= = --_f337f452-dac6-4314-9581-64708d70164f_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
=0A= I am using Aptana Studio 3 to write a small application.
=0A= =0A= In the Views folder=2C I added a new .html.erb page and added a jQuery =0A= navigation menu bar. This page also has a banner. I want to keep this as=0A= a base page (like Master Page in .NET) for all the other pages.
=0A= =0A= I want all the other pages to automatically show the banner and menu bar on= top.
=0A= =0A= How to do this? I am using Rails 3.2.
=0A= =0A=

=0A= =0A= Code of application.html.erb:
=0A= =0A=
<=3B!DOCTYPE html>=3B=0A=
<=3Bhtml>=3B=0A=
<=3Bhead>=3B=0A=
  <=3Btitle<=
span class=3D"pun">>=3B<=3B/title>=3B=0A=
  <=3B%=3D styleshe=
et_link_tag    "application"=2C :=
media =3D>=3B "all" =
%>=3B=0A=
  <=3B%=3D javascri=
pt_include_tag "application" %>=3B=0A=
  <=3B%=3D csrf_met=
a_tags %>=3B=0A=
=0A=
      <=3Bscript ty=
pe=3D"text/javascript=
" src=3D"..\Libraries\jquery.min.js">=3B=
<=3B/script>=3B=0A=
      <=3Bscript ty=
pe=3D"text/javascript=
">=3B=0A=
            $(documen=
t).ready(function(){=0A=
                    $('li.headlink').hover=
(=0A=
                        function() { $('ul'=2C this).css('display'=2C=
 'block')=3B }=2C=0A=
                        function() { $('ul'=2C this).css('display'=2C=
 'none')=3B })=3B=0A=
                })=3B=
   =0A=
      <=3B/script>=3B=0A=
      <=3Bstyle typ=
e=3D"text/css"=
 rel=3D"stylesheet">=3B=0A=
            /* General */=0A=
            #cssdropdown=2C #cssdropdown ul { li=
st-style: none=3B }=0A=
            #cssdropdown=2C #cssdropdown * { pad=
ding: 0=3B margin: 0=3B }=0A=
=0A=
            /* Head links */=0A=
            #cssdropdown li.headlink { width: 22=
0px=3B float: left=3B margin-left: -1px=3B border: 1px black solid=3B backg=
round-color: #e9e9e9=3B text-align: center=3B }=
=0A=
            #cssdropdown li.headlink a { display=
: block=3B padding: 15px=3B }=0A=
=0A=
            /* Child lists and links */=0A=
            #cssdropdown li.headlink ul { displa=
y: none=3B border-top: 1px black solid=3B text-align: left=3B }=0A=
            #cssdropdown li.headlink:hover ul { =
display: block=3B }=0A=
            #cssdropdown li.headlink ul li a { p=
adding: 5px=3B height: 17px=3B }=0A=
            #cssdropdown li.headlink ul li a:hov=
er { background-color: LightBlue=3B color:Black }=0A=
=0A=
            /* Pretty styling */=0A=
            body { fo=
nt-family: verdana=2C arial=2C sans-serif=3B font-size: 0.8em=3B}=0A=
            #cssdropdown a { color: white=3B } #=
cssdropdown ul li a:hover { text-decoration: none=3B }=0A=
            #cssdropdown li.headlink { backgroun=
d-color: Blue=3B}=0A=
            #cssdropdown li.headlink ul { backgr=
ound-position: bottom=3B padding-bottom: 10px=3B }=0A=
      <=3B/style>=3B  =0A=
<=3B/head>=3B=0A=
<=3Bbody>=3B=0A=
<=3B%=3D yield %>=3B=0A=
=0A=
        <=3Bdiv id<=
/span>=3D"divMain">=3B=0A=
            <=3Bdiv=
 id=3D"divHeader">=3B=0A=
                <=3Bimg src=3D"..\Images=
\W.png">=3B        =
         =0A=
            <=3B/di=
v>=3B=0A=
            <=3Bdiv=
 id=3D"divMenu">=3B=0A=
                <=3Bul id=3D"cssdropdown=
">=3B=0A=
                <=3Bli class=3D"headlink">=3B=0A=
                    <=3Ba href=3D"#">=3BTask<=3B/a&=
gt=3B=0A=
                     <=3Bul>=3B=0A=
                      <=3Bli>=3B<=3Ba href=3D"#"=
>=3BAdd New<=3B/a>=3B<=3B/li>=3B=0A=
                     <=3B/ul>=3B=0A=
                     <=3B/li>=3B=0A=
                      <=3Bli class=3D<=
/span>"headlink">=3B=0A=
                      <=3Ba href=3D"#"=
>=3BReports<=
span class=3D"pun"><=3B/a>=3B    =0A=
                         <=3Bul>=3B=0A=
                      <=3Bli>=3B<=3Ba href=3D"#"=
>=3BReport<=3B/a>=3B<=3B/li>=3B=
=0A=
                     <=3B/ul>=3B=0A=
                 <=3B/li>=3B=0A=
                <=3B/ul>=3B           =
    =0A=
            <=3B/di=
v>=3B=0A=
        <=3B/div>=3B=0A=
=0A=
<=3Bdiv id=3D"content">=3B<=3B%=3D content_for?(:content) ? yield(=
:content) : yield %>=3B<=3B/div>=3B         =0A=
<=3B/body>=3B=0A=
<=3B/html>=3B
=0A= =0A= Code of Content.html.erb
=0A= =0A=
=0A=
        <=3B% conte=
nt_for :content do %>=3B=0A=
          <=3Bdiv i=
d=3D"divMain"<=
span class=3D"pun">>=3B<=3B/div>=3B=0A=
          <=3B%=3D =
content_for?(:news_co=
ntent) ? yield<=
/span>(:news_content<=
span class=3D"pun">) =
: yield %>=3B=
=0A=
        <=3B% end %>=3B=0A=
        <=3B%=3D re=
nder :template =3D>=3B 'layouts/application' %>=3B=0A=
=0A= =0A=
= --_f337f452-dac6-4314-9581-64708d70164f_--