Here is my layout file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>My Demands</title> <%= stylesheet_link_tag ''ajax_scaffold'', :media => ''all'' %> <%= javascript_include_tag ''prototype'', ''effects'', ''rico_corner'', ''ajax_scaffold'' %> </head> <body> <div id="container"> <%= @content_for_layout %> </div> </body> </html> After I start up the Webrick server,the html source will be as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>My Demands</title> <link href="/stylesheets/ajax_scaffold.css" media="all" rel="Stylesheet" type="text/css" /> <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/rico_corner.js" type="text/javascript"></script> <script src="/javascripts/ajax_scaffold.js" type="text/javascript"></script> </head> <body> <div id="container"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>My Demands</title> <link href="/stylesheets/ajax_scaffold.css" media="all" rel="Stylesheet" type="text/css" /> <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/rico_corner.js" type="text/javascript"></script> <script src="/javascripts/ajax_scaffold.js" type="text/javascript"></script> </head> <body> <div id="container"> ... It seems that @content_for_layout will contain all the content include the part before <body>,how can it happen? very thanks! -- Posted via http://www.ruby-forum.com/.
Most likely you have that content in your .rhtml files too Tauraus wrote:> It seems that @content_for_layout will contain all the content include > the part before <body>,how can it happen? very thanks!-- Posted via http://www.ruby-forum.com/.
Cheltis wrote:> Most likely you have that content in your .rhtml files too > > Tauraus wrote: >> It seems that @content_for_layout will contain all the content include >> the part before <body>,how can it happen? very thanks!I had examined other rhtml file for times,but it does not exist at all.. -- Posted via http://www.ruby-forum.com/.
Tauraus wrote:> Cheltis wrote: >> Most likely you have that content in your .rhtml files too >> >> Tauraus wrote: >>> It seems that @content_for_layout will contain all the content include >>> the part before <body>,how can it happen? very thanks! > > I had examined other rhtml file for times,but it does not exist at all..I got the reason,but I still do not know how to resolve this problem. It is because of my using pagination. Here is the demands_controller: def index end def list @pages = Paginator.new self, Demand.count, 10, @params[:page] @demands = Demand.find(:all, :order => ''reply_times DESC'', :limit => 10, :offset => @pages.current.offset) end Here is the index.rhtml: <%= render_component :controller => ''demands'', :action => ''list'' %> it is generated by the Ajaxscaffold. if the url refers to : http://127.0.0.1:3000/demands or http://127.0.0.1:3000/index then the above error will happen if the url refers to : http://122.0.0.1:3000/demands/list then everything is ok Can anybody tell me the reason? very thanksful! -- Posted via http://www.ruby-forum.com/.
OK, now it looks clear layout is dublicated because it applied twice you should put something like this in your controller layout "your_layout", :except => ''list'' however, correct way of doing this would be removing index.rhtml and changing index action to def index list render :action => ''list'' end Tauraus wrote:> I got the reason,but I still do not know how to resolve this problem. > It is because of my using pagination. > Here is the demands_controller: > > def index > end > > def list > @pages = Paginator.new self, Demand.count, 10, @params[:page] > @demands = Demand.find(:all, :order => ''reply_times DESC'', :limit => > 10, :offset => @pages.current.offset) > end > > Here is the index.rhtml: > <%= render_component :controller => ''demands'', :action => ''list'' %> > it is generated by the Ajaxscaffold. > > if the url refers to : http://127.0.0.1:3000/demands or > http://127.0.0.1:3000/index > then the above error will happen > if the url refers to : http://122.0.0.1:3000/demands/list > then everything is ok > > Can anybody tell me the reason? very thanksful!-- Posted via http://www.ruby-forum.com/.
Cool,aha! Thanks a lot,Cheltis :-) Cheltis wrote:> OK, now it looks clear > > layout is dublicated because it applied twice > > you should put something like this in your controller > layout "your_layout", :except => ''list'' > > however, correct way of doing this would be removing index.rhtml and > changing index action to > > def index > list > render :action => ''list'' > end-- Posted via http://www.ruby-forum.com/.