Skip to content

Instantly share code, notes, and snippets.

Answers new method
def new
@survey = Survey.find(params[:survey_id])
@questions = @survey.questions.all
@answers = @questions.map{|q| q.answers.build}
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @answer }
end
search.html.erb
<%= form_tag(:action => "search") do %>
<%= label_tag(:q, "Search for:") %>
<%= text_field_tag(:wth) %>
<%= submit_tag("Search") %>
<% end %>
--
def getUriQuery(url)
dots = url.scan(/\./)
dotsSize = dots.size
httpRegex = '(?![https?:\/\/])'
minimumUriRegex = '([^.]+\.[^.]+\...|[^.]+\.[^.]+)$' # Credit to @blaines
dotsSize -= 1
appendableRegex = '[^.]+\.'*dotsSize
customUriRegex = minimumUriRegex.insert(18, appendableRegex).insert(1, appendableRegex)
fullUriRegex = httpRegex + customUriRegex
uriToQuery = url.slice(Regexp.new(fullUriRegex))
@salbito
salbito / person.rb
Created January 18, 2010 14:41 — forked from Mikr0Tik/person.rb
class Person < ActiveRecord::Base
before_update :before_update_changes
attr_accessor :update_changes
def before_update_changes
@update_changes = changes
end
end