Skip to content

Instantly share code, notes, and snippets.

resource :contacts, :only => [], :path => 'rsvp' do
get :new
post :create
end
#this is sort of ridiculous, is there a better way?
resource :contacts, :only => [], :path => 'rsvp' do
get :new
get :thank
post :create
end
<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 />
test "paypal validation helper" do
address = "1 Main St"
zipcode = 95131
emails = %w{
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
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
<%= 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 %>
#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]
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"}
<%= form_for(@new_product_template,
:url => opportunity_new_product_template_path(@opportunity),
:html => {:method => :put, :multipart => true}) do |f| %>
class Foo < ActiveRecord::Base
has_many :bars
end
class Bar < ActiveRecord::Base
belongs_to :foo, :polymorphic => true #is polymorphic even needed?
end
class Baz < Bar
end