Skip to content

Instantly share code, notes, and snippets.

View kirkbushell's full-sized avatar

Kirk Bushell kirkbushell

  • Creative Force
  • Sydney
View GitHub Profile
# in controller method
@user = User.find_by_email(params[:email])
if @user.nil?
flash.now[:error] = 'No user found by that email address'
end
# view (in haml)
- unless flash.nil?
- if flash[:notice]
@kirkbushell
kirkbushell / whatever
Created August 15, 2011 00:06
nested models problem
#models
class Link < ActiveRecord::Base
has_many :link_urls
accepts_nested_attributes_for :link_urls, :allow_destroy => true #, :reject_if => lambda { |a| a[:url].blank? }
end
class LinkUrl < ActiveRecord::Base
belongs_to :link
end