This code was working before I created the update_link_list method in
the helper below (everything was in the controller). I can successfully
create a new link but I get a TypeError when I leave all form fields
blank -- I expect to see validation error messages.
Code:#link_controller.rb: def create link = Link.new(params[:link]) saved = link.save num_links = Link.find(:all).size num_cats = Category.find(:all).size if request.xhr? render:update do |page| page.update_link_list(link, saved, num_links, num_cats) end return end if saved flash[:message] = 'Link was successfully created.' redirect_to :action => 'list' else render :action => 'new' end endI'm receiving this error:Code:#link_controller helper: def update_link_list(new_link, was_saved, num_links, num_cats) if was_saved page['listing-status'].replace_html "You've created #{num_links} links in #{num_cats} categories" page['no-links'].remove if num_links == 1 && page['no-links'] page.insert_html :after, "category-#{new_link.category_id}", :partial => 'link', :object => new_link page.visual_effect :highlight, "link-#{new_link.id}" page.replace_html 'new_link_error', '' page['link_url'].value = 'http://' page['link_name'].value = '' page['link_description'].value = '' else # not saved, present error messages page.replace_html 'new_link_error', error_messages_for(new_link) page.visual_effect :appear, 'new_link_error', :duration => 0.5 page.visual_effect :highlight, 'new_link_error', :duration => 0.5 end end
No clue how to fix this. Any ideas? Many thanks...Code:TypeError in Publish/linksController#create ActionView::Helpers::JavaScriptProxy#to_str should return String




Bookmarks