I am trying to use the tabs function from jQuery UI in a Rails app. I am using a helper for the navigation and I would like to keep it that way. The code in my helper is: def links_for_navigation html = "" html = <<HTML <ul> <li><a href="#tabs-1">Courses</a></li> <li><a href="#tabs-2">Parts</a></li> <li><a href="#tabs-3">Categories</a></li> </ul> <div id="tabs-1"><% link_to "Courses", courses_path %> <div id="tabs-2"><% link_to "Parts", parts_path %> <div id="tabs-3"><% link_to "Categories", categories_path %> HTML end My view pulls in the code with <% links_for_navigation %> I added to my application.js: jQuery(function() { jQuery("#tabs").tabs(); }); And my application.html.erb has: <%= stylesheet_link_tag ''courses'', ''jquery-ui-1.8.13.custom.css'' %> <%= javascript_include_tag :defaults %> <%= javascript_include_tag ''jquery-1.5.1.min.js'', ''jquery- ui-1.8.13.custom.min.js'', ''application'' %> When I try to load the page I get "cannot find string HTML before EOF What am I doing wrong? Thanks is advance!! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 8, 9:01 pm, Bob Roberts <brobe...-G3KodTVGE9tBDgjK7y7TUQ@public.gmane.org> wrote:> I am trying to use the tabs function from jQuery UI in a Rails app. I > am using a helper for the navigation and I would like to keep it that > way. The code in my helper is: > > def links_for_navigation > html = "" > html = <<HTML > <ul> > <li><a href="#tabs-1">Courses</a></li> > <li><a href="#tabs-2">Parts</a></li> > <li><a href="#tabs-3">Categories</a></li> > </ul> > > <div id="tabs-1"><% link_to "Courses", courses_path %> > <div id="tabs-2"><% link_to "Parts", parts_path %> > <div id="tabs-3"><% link_to "Categories", categories_path %> > HTML > end > > My view pulls in the code with <% links_for_navigation %> > > I added to my application.js: > > jQuery(function() { > jQuery("#tabs").tabs(); > > }); > > And my application.html.erb has: > > <%= stylesheet_link_tag ''courses'', ''jquery-ui-1.8.13.custom.css'' %> > <%= javascript_include_tag :defaults %> > <%= javascript_include_tag ''jquery-1.5.1.min.js'', ''jquery- > ui-1.8.13.custom.min.js'', ''application'' %> > > When I try to load the page I get "cannot find string HTML before EOF > > What am I doing wrong? > > Thanks is advance!!It''s telling you that is can''t fine your HTML template before it reaches the end of the file it is processing. It may be that the frame work is looking for your HTML template at the end of the file that is making the call and not the helper. Personally I don''t like using the inline template in a method because it doesn''t allow you to easily change the template without touching that method. I would save the template off to it''s own file in the view folder (somthing like tabs.html.erb) and then in the helper method read and process the template returning the result to whaterver called it. def links_for_navigation template = ERB.new File.read("tabs.html.erb") html= template.result(binding) end B. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 8, 10:01 pm, Bob Roberts <brobe...-G3KodTVGE9tBDgjK7y7TUQ@public.gmane.org> wrote:> I am trying to use the tabs function from jQuery UI in a Rails app. I > am using a helper for the navigation and I would like to keep it that > way. The code in my helper is: > > def links_for_navigation > html = "" > html = <<HTML > <ul> > <li><a href="#tabs-1">Courses</a></li> > <li><a href="#tabs-2">Parts</a></li> > <li><a href="#tabs-3">Categories</a></li> > </ul> > > <div id="tabs-1"><% link_to "Courses", courses_path %> > <div id="tabs-2"><% link_to "Parts", parts_path %> > <div id="tabs-3"><% link_to "Categories", categories_path %> > HTML > end> When I try to load the page I get "cannot find string HTML before EOF > > What am I doing wrong?The terminating string for a here-doc can''t be indented - so that''s your first problem. I''m hoping that the missing </div> tags are just a typo in the above, as are the missing =s on the ERB tags (not going to get much output...). As written, you''re actually going to get the ERB tags un- interpreted in the output HTML. Take a look at the Layouts and Rendering guide: http://guides.rubyonrails.org/layouts_and_rendering.html specifically the parts about partials for a cleaner way to do this. --Matt Jones -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 10, 2011, at 9:45 AM, Matt Jones wrote:> On Jun 8, 10:01 pm, Bob Roberts <brobe...-G3KodTVGE9tBDgjK7y7TUQ@public.gmane.org> wrote: >> I am trying to use the tabs function from jQuery UI in a Rails >> app. I >> am using a helper for the navigation and I would like to keep it that >> way. The code in my helper is: >> >> def links_for_navigation >> html = "" >> html = <<HTML >> <ul> >> <li><a href="#tabs-1">Courses</a></li> >> <li><a href="#tabs-2">Parts</a></li> >> <li><a href="#tabs-3">Categories</a></li> >> </ul> >> >> <div id="tabs-1"><% link_to "Courses", courses_path %> >> <div id="tabs-2"><% link_to "Parts", parts_path %> >> <div id="tabs-3"><% link_to "Categories", categories_path %> >> HTML >> end > >> When I try to load the page I get "cannot find string HTML before EOF >> >> What am I doing wrong? > > The terminating string for a here-doc can''t be indented - so that''s > your first problem.unless you reference the here-doc like: html = <<-HTML <ul> ... HTML That extra ''-'' in the <<-HTML allows the ending token to be indented. -Rob> > I''m hoping that the missing </div> tags are just a typo in the above, > as are the missing =s on the ERB tags (not going to get much > output...). As written, you''re actually going to get the ERB tags un- > interpreted in the output HTML. > > Take a look at the Layouts and Rendering guide: > > http://guides.rubyonrails.org/layouts_and_rendering.html > > specifically the parts about partials for a cleaner way to do this. > > --Matt Jones > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 > . >Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.