pureflight1080
2006-Dec-31 23:03 UTC
Is the equality failing or is something else going on?
I''m trying to prototype, but I''m running into an error after modifying the scaffolding slightly. if(column.name == ''content'') page.send(column.name) else render_template ''rhtml'', page.send(column.name) end I have a datetime field and I''m getting this error "can''t convert Time into String" and the render_template line is causing the problem. The ''content'' column isn''t a datetime field. So the if statement is failing. Another question, I''m trying to pretty this up using an ''unless'' statement but I can''t seem to figure it out <%= page.send unless column.name ==''content'' render_template ''rhtml'', page.send(column.name) %> doesn''t seem to work either. Rails spits out a problem with a missing '')'' after ''render_template''. Any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Duane Johnson
2007-Jan-01 16:56 UTC
Re: Is the equality failing or is something else going on?
On Dec 31, 2006, at 4:03 PM, pureflight1080 wrote:> > I''m trying to prototype, but I''m running into an error after modifying > the scaffolding slightly. > > if(column.name == ''content'') > page.send(column.name) > else > render_template ''rhtml'', page.send(column.name) > end > > I have a datetime field and I''m getting this error "can''t convert Time > into String" and the render_template line is causing the problem. The > ''content'' column isn''t a datetime field. So the if statement is > failing. >It looks like you''re using the old-style render_template... not sure if that''s causing difficulty or not. Try this: render :template => "path/to/template" You could try this too, although I''m not certain I''m thinking the same thing you''re thinking: render :template => "path/to/#{column.name}", :locals => {:value => page.send(column.name)} Then, in each of your #{column.name}.rhtml files, you will have a local variable called ''value'' which contains the value of the relevant column.> Another question, I''m trying to pretty this up using an ''unless'' > statement but I can''t seem to figure it out > > <%= page.send unless column.name ==''content'' render_template ''rhtml'', > page.send(column.name) %> doesn''t seem to work either. Rails spits > out > a problem with a missing '')'' after ''render_template''. Any ideas? >It looks like you''re trying to do an unless / else statement on one line, so you''ll need a ''then'' and an ''else''. You''ll also need to clean up the code a little, as it seems you''re not actually ''send''ing anything to ''page''... actually, I''m not sure about that, but the Ruby syntax isn''t right anyway, so maybe that''s why the parser in my head won''t work :) <%= unless column.name ==''content'' then render_template(''rhtml'', page.send(column.name)) else page.send(column.name) end %> Duane Johnson (canadaduane) http://blog.inquirylabs.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---