1
SyntaxError in Videos#show

Showing /rubyprograms/dreamstill/app/views/videos/show.html.erb where line #54 raised:

compile error
/Library/Ruby/Gems/1.8/gems/activemodel-3.0.4/lib/active_model/attribute_methods.rb:272: syntax error, unexpected ')'
/Library/Ruby/Gems/1.8/gems/activemodel-3.0.4/lib/active_model/attribute_methods.rb:273: syntax error, unexpected '?', expecting $end
Extracted source (around line #54):

51:         <%= link_to "Show Song", '#', :id => 'video_show_link', :class => 'edit' %>
52:     
53:         <div id="showable_video_div">
54:             <%= form_for [@video, @video.showable_videos.new ], :url => showable_videos_path, :remote => true do |f| %>
55:                 <%= f.hidden_field :video_id, :value => @video.id, :id => "video_id_field" %>
56:                 <%= f.text_field :user, :class => "showable_field" %>
57:             <% end %>

This is the migration to the showable_videos table that I did right before the error was thrown:

class AddUpvotedAndSeenToShowableVideos < ActiveRecord::Migration
  def self.up
    add_column :showable_videos, :upvoted?, :boolean
    add_column :showable_videos, :seen?, :boolean
  end

  def self.down
    remove_column :showable_videos, :seen?
   remove_column :showable_videos, :upvoted?
  end
end
5
  • What's [@video, @video.showable_videos.new] supposed to yield? Commented May 20, 2011 at 4:44
  • 1
    The syntax error is in your title. Wheres ==> Where's Commented May 20, 2011 at 4:47
  • in the video model: has_many :showable_videos Commented May 20, 2011 at 4:47
  • @user730569 theIV got it. You didn't get it. Commented May 20, 2011 at 4:50
  • actually this migration may have something to do with this error ^^ Commented May 20, 2011 at 5:09

1 Answer 1

1

I just undid the migration above and then ran the migration again without the ? in the column names. I no longer get the syntax error.

Sign up to request clarification or add additional context in comments.

2 Comments

Indeed that would fixed it, Rails automatically provides those methods so if you add it yourself on that column it won't work.
You should accept your answer ;) You may also report a bug in Rails (I guess it may also be a bug in the documentation). Rails should return an error saying that question marks are not legal in Rails table column names. PostgreSQL, for example, allows you to create such columns. Since Rails define reader methods with question marks ("name?" for attribute "name") using this character in the base column may be questionable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.