ok i have partial defined like this <% d = Date.today %> <div class="date_container"> <div class="month"><%= Date::ABBR_DAYNAMES[d.wday] %></div> <div class="day"><%= d.day %></div> <div class="year"><%= Date::ABBR_MONTHNAMES[d.mon] %></div> </div> <!-- date container--> now whats annoying is when it renders i get this 2006-06-14 <--- why is this being rendered ? & then my css formatted date below Tue 22 Jun Not sure why it printing out the whole date at the top when im assigning it to a variable. anyone any idea on what im doing wrong above or is this simply running as expected thanks pete -- Posted via http://www.ruby-forum.com/.
<%= ... that means display the results of the code to the browser. You want <% d = Date.today %> Jeremy On Jun 17, 2006, at 10:15 PM, Pete Gajria wrote:> ok i have partial defined like this > > <%> d = Date.today > %> > > <div class="date_container"> > <div class="month"><%= Date::ABBR_DAYNAMES[d.wday] %></div> > <div class="day"><%= d.day %></div> > <div class="year"><%= Date::ABBR_MONTHNAMES[d.mon] %></div> > </div> <!-- date container--> > > > now whats annoying is when it renders i get this > > 2006-06-14 <--- why is this being rendered ? > & then my css formatted date below > Tue > 22 > Jun > > Not sure why it printing out the whole date at the top when im > assigning > it to a variable. > > anyone any idea on what im doing wrong above or is this simply running > as expected > > thanks > pete > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Pete, Pete Gajria wrote:>is this simply running > as expected (?)It''s doing exactly what you told it to do ;-) Under the MVC paradigm, you should be doing the assignment in your controller and making the result available to your view via an instance variable. Move ''d = Date.today'' to your controller action, changing ''d'' to ''@d'' (else your view won''t have access to it). Then in your view, use @d.wday, @d.day, etc. If, for some reason, you really, really, really need to do the assignment in your view, use <%... rather than <%=... hth, Bill