Forum: Ruby on Rails Automatic .santize?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1ec9c0fe62f845c65fa2fb0d2ff46ebc?d=identicon&s=25 Programmer (Guest)
on 2006-05-31 22:06
Hello and thanks in advance to those who post back,

I'm working on a calender but, it renders the data in the controller
then saves it as @code so I call it in the veiw <%= @code %>. So
everythings working and I add this line..
@event =
Event.find_by_date("#{@temp13.year}-#{@temp13.month}-#{@temp13.day}")
if @event == nil
 @@td = "<td width=50 height=50
valign=top><small><b>#{@temp13.to_s[0,3]} |
#{@temp13.day}</b></small></td>"
 @@ntd = "<td width=50 height=50 valign=top><small>#{@temp13.to_s[0,3]}
| #{@temp13.day}</small></td>"
else
 @@td = "<td width=50 height=50
valign=top><small><b>#{@temp13.to_s[0,3]} | #{@temp13.day}</b><br><%=
link_to @event.title, :action => :show_date, :id => @event.id
%></small></td>"
 @@ntd = "<td width=50 height=50 valign=top><small>#{@temp13.to_s[0,3]}
| #{@temp13.day}<br><%= link_to @event.title, :action => :show_date, :id
=> @event.id %></small></td>"
end
now when I run it on the days with events it shows <%= link_to
@event.title, :action => :show_date, :id => @event.id %> why dosn't it
run the code? Is there a way around this or do I need to move my code in
to my templete?
6076c22b65b36f5d75c30bdcfb2fda85?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-05-31 23:48
(Received via mailing list)
On May 31, 2006, at 1:06 PM, Programmer wrote:

> #{@temp13.day}</b></small></td>"
> | #{@temp13.day}<br><%= link_to @event.title, :action
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails


You need to move that code into the view file where it belongs. Doing
it in your controller like that will not evaluiate the erb template
statements so you get the results you are currently seeing. Also I am
wondering why you are using class variables here @@ ? THey will cause
you problems so you shouldn't use them unless you have a very good
reason to do so.

	You could also use much better and more descriptive variable names.
temp1 temp2 are horrible names for vars. ALso there is a calendar
helper already available that might save you a ton of work here:

http://www.jvoorhis.com/pages/calendar-helper

Cheers-
-Ezra
This topic is locked and can not be replied to.