Skip to content

Instantly share code, notes, and snippets.

<%= form_for(@new_product_template,
:url => opportunity_new_product_template_path(@opportunity),
:html => {:method => :put, :multipart => true}) do |f| %>
opportunities GET /questionnaires(.:format) {:action=>"index", :controller=>"opportunities"}
opportunities POST /questionnaires(.:format) {:action=>"create", :controller=>"opportunities"}
new_opportunity GET /questionnaires/new(.:format) {:action=>"new", :controller=>"opportunities"}
edit_opportunity GET /questionnaires/:id/edit(.:format) {:action=>"edit", :controller=>"opportunities"}
opportunity GET /questionnaires/:id(.:format) {:action=>"show", :controller=>"opportunities"}
opportunity PUT /questionnaires/:id(.:format) {:action=>"update", :controller=>"opportunities"}
opportunity DELETE /questionnaires/:id(.:format) {:action=>"destroy", :controller=>"opportunities"}
#in the form
<% if @opportunity.opportunity_filters.size > 0 %>
<% f.fields_for :opportunity_filters do |filter_form| %>
<%= render 'opportunity_filters/edit_form',
:locals => {:foo => @opportunity.opportunity_filters[0], :f => filter_form} %>
<% end %>
<% end %>
#the partial [just for testing, filter_type is an attribute of opportunity_filter]
<%= form_for(@opportunity) do |f| %>
#...
<% f.fields_for :opportunity_filters do |filter_form| %>
<%= render 'opportunity_filters/edit_form',
:collection => @opportunity.opportunity_filters,
:as => :opportunity_filter, :locals => {:f => filter_form} %>
<% end %>
#..
<% end %>
def check_username_is_allowed
RESTRICTED_NAMES.each do |restricted|
- errors.add(:username, "is not available") if
- username =~ /#{restricted}/i unless errors.on(:username)
+ errors[:username] << "is not available" if
+ username =~ /#{restricted}/i unless errors[:username] and errors[:username].size != 0
end
end
test "paypal validation helper" do
address = "1 Main St"
zipcode = 95131
emails = %w{
foo_1284577745_per@gmail.com
FOO_1284577745_per@gmail.com
foo_1284577745_per@GMAIL.com
FoO_1284577745_per@GmAiL.Com
FoO_1284577745_per@GmAiL.CoM
<div id="edit_user_form" class="blue_fields">
<%= form_for [:admin, @user] do |f| %>
<%= qm_error_messages("account information", @user) %>
<div>
<%= f.check_box :admin %>
<%= f.label :admin, "Is an admin?" %>
</div>
<br />
#this is sort of ridiculous, is there a better way?
resource :contacts, :only => [], :path => 'rsvp' do
get :new
get :thank
post :create
end
resource :contacts, :only => [], :path => 'rsvp' do
get :new
post :create
end