On May 31, 2006, at 1:06 PM, Programmer wrote:
> 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?
>
> --
> 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