Skip to content

Instantly share code, notes, and snippets.

@meltzerj
Created May 21, 2011 21:59
Show Gist options
  • Save meltzerj/984937 to your computer and use it in GitHub Desktop.
Save meltzerj/984937 to your computer and use it in GitHub Desktop.
SyntaxError in Profiles#shown_songs
Showing /rubyprograms/dreamstill/app/views/videos/_shown_video.html.erb where line #4 raised:
/rubyprograms/dreamstill/app/models/video_vote.rb:11: syntax error, unexpected '(', expecting '}'
...ate_timeline_event.inspect}" (((vote.value == 1) || (vote.va...
^
/rubyprograms/dreamstill/app/models/video_vote.rb:11: syntax error, unexpected ')', expecting '}'
...create_timeline_event != true) }
^
/rubyprograms/dreamstill/app/models/video_vote.rb:28: syntax error, unexpected kEND, expecting '}'
def self.set_shown_upvote_event(upvote, actor_id, subject_id, secondary_subject_id, vote)
vote.dont_create_timeline_event == true
if upvote == true
create(:actor_id => actor_id, :actor_type => 'User', :subject_id => subject_id, :subject_type => 'User', :secondary_subject_id => secondary_subject_id, :secondary_subject_type => 'Video', :event_type => 'shown_upvote_event' )
elsif upvote == false
create(:actor_id => actor_id, :actor_type => 'User', :subject_id => subject_id, :subject_type => 'User', :secondary_subject_id => secondary_subject_id, :secondary_subject_type => 'Video', :event_type => 'shown_upvote_event' )
else upvote == nil
#find_by_actor_id_and_subject_id_and_secondary_subject_id_and_event_type(actor_id, subject_id, secondary_subject_id, 'shown_upvote_event').destroy
end
end
belongs_to :actor, :polymorphic => true
belongs_to :subject, :polymorphic => true
belongs_to :secondary_subject, :polymorphic => true
attr_accessor :dont_create_timeline_event
fires :vote_updated, :on => :update,
:actor => :user,
:secondary_subject => :video,
:if => lambda { |vote| (((vote.value == 1) || (vote.value == -1)) && vote.dont_create_timeline_event != true) }
def create
@video = Video.find(params[:video_id])
@vote = current_user.video_votes.find_or_create_by_video_id(@video.id)
if @vote.value.nil?
if params[:type] == "up"
@vote.value = 1
@upvoted = true
else
@vote.value = -1
@upvoted = false
end
elsif (params[:type] == "up" && @vote.value == 1) || (params[:type] == "down" && @vote.value == -1)
@vote.value = 0
@upvoted = nil
elsif ((params[:type] == "up" && @vote.value == -1) || (params[:type] == "down" && @vote.value == 1)) || (@vote.value == 0)
if params[:type] == "up"
@vote.value = 1
@upvoted = true
else
@vote.value = -1
@upvoted = false
end
end
if params[:showable_video_id]
@showable_video = ShowableVideo.find_by_id(params[:showable_video_id])
@showable_video.update_attributes(:upvoted => @upvoted)
TimelineEvent.set_shown_upvote_event(@upvoted, current_user.id, @showable_video.user_id, @showable_video.video_id, @vote)
end
unless @vote.user == @video.user
if @vote.save
respond_to do |format|
format.html { redirect_to @video }
format.js
end
else
respond_to do |format|
format.html
format.js
end
end
end
end
@nilbus
Copy link

nilbus commented May 21, 2011

attr_accessor :dont_create_timeline_event

@nilbus
Copy link

nilbus commented May 21, 2011

                   :if => lambda { |vote| (((vote.value == 1) || (vote.value == -1)) && vote.dont_create_timeline_event != true) }

                   :if => lambda { |vote| puts "Don't create? #{vote.dont_create_timeline_event.inspect}"
                                                  (((vote.value == 1) || (vote.value == -1)) && vote.dont_create_timeline_event != true) }

@meltzerj
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment