Skip to content

Instantly share code, notes, and snippets.

@meltzerj
Created April 3, 2011 22:08
Show Gist options
  • Select an option

  • Save meltzerj/900873 to your computer and use it in GitHub Desktop.

Select an option

Save meltzerj/900873 to your computer and use it in GitHub Desktop.
#Link in video show view
<%= link_to "Enable Commenting", new_comment_title_path(:format => :js), :id => 'enable_commenting_link', :class => 'edit' %>
#comment_titles/new.js.erb
$("<%= escape_javscript render(:file => 'comment_titles/new.html.erb') %>").insertAfter('#enable_commenting_link');
$('#enable_commenting_link').hide();
#comment_titles/new.html.erb
<%= simple_form_for setup_video(@video) do |f| %>
<% f.fields_for :comment_titles do |t| %>
<% if t.object.new_record? %>
<%= t.input :title, :label => "Comment Title:" %>
<%= t.button :submit, :value => 'Add', :id => 'add_comment_title' %>
<div class='hint'>Let your listeners know what comments you want by adding a guiding title for them. Pose a question, ask for feedback, or anything else!</div>
<% end %>
<% end %>
<% end %>
#I get this error when I click on a#enable_commenting_link:
NoMethodError in Comment_titles#new
Showing /rubyprograms/dreamstill/app/views/comment_titles/new.html.erb where line #1 raised:
undefined method `comment_titles' for nil:NilClass
Extracted source (around line #1):
1: <%= simple_form_for setup_video(@video) do |f| %>
#This is the application trace:
app/helpers/application_helper.rb:10:in `setup_video'
app/helpers/application_helper.rb:9:in `setup_video'
app/views/comment_titles/new.html.erb:1:in `_app_views_comment_titles_new_html_erb___1915748124_2173075480_0'
app/views/comment_titles/new.js.erb:1:in `_app_views_comment_titles_new_js_erb___1561617140_2173096440_0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment