Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


user.rb

1
2
3
4
5
6
7
class User < ActiveRecord::Base
  attr_accessible :id, :name, :zipcode

  has_one :authentication, :inverse_of => :user, :dependent => :destroy
  accepts_nested_attributes_for :authentication
end

authentication.rb

1
2
3
4
5
6
7
class Authentication < ActiveRecord::Base
  attr_accessible :id, :user_id, :email

  has_one :authenticationdetail
  belongs_to :user
end

authenticationdetail.rb

1
2
3
4
class Authenticationdetail < ActiveRecord::Base
  belongs_to :authentication
end

authentications_controller.rb

1
2
3
4
5
6
7
8
9
10
11
12
class AuthenticationsController < ApplicationController
  def new 
    @user ||= User.find(params[:user_id] if params[:user_id]
    if @user
      @user.build_authentication(:user_id => @user.id)
    else
      redirect_to root_path
      flash[:notice] = "Error occured"
    end
  end
end

authentication form

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<%= form_for @user do |a| %>
  <% @user.errors.full_messages.each do |msg| %>
    <p><%= msg %></p>
  <% end %>
  <%= a.fields_for :authentication do |builder| %>
    <div>
      <p>
        <%= builder.label :email %>
        <%= builder.text_field :email %>
      </p>
      <p>
        <%= builder.label :email_confirmation %>
        <%= builder.text_field :email_confirmation %>
      </p>
    </div>
  <% end %>
  <p class="submit">
    <%= a.submit "continue" %>
  </p>
<% end %>