Skip to content

Instantly share code, notes, and snippets.

@mvr
Created January 12, 2010 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvr/274810 to your computer and use it in GitHub Desktop.
Save mvr/274810 to your computer and use it in GitHub Desktop.
def create
@number = Number.find_or_create_by_value(:value => params[:value])
if not @number.valid?
@fact = Fact.new(params[:fact])
@intended_value = @number.value
render 'facts/new' and return
end
@fact = @number.facts.new(params[:fact])
if @fact.save
session[:votes] << @fact.id
redirect_to number_path(@number)
else
render 'facts/new'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment