Created
September 27, 2012 05:03
-
-
Save JFickel/3792252 to your computer and use it in GitHub Desktop.
received_notes not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| has_many :notes, foreign_key: "sender_id", dependent: :destroy | |
| has_many :outgoing_notes, through: :notes, source: :user_recipient | |
| has_many :incoming_notes, as: :receivable , | |
| class_name: "Note", | |
| dependent: :destroy | |
| has_many :received_notes, through: :incoming_notes, source: :sender | |
| end | |
| class Note < ActiveRecord::Base | |
| attr_accessible :description, :sender_id, :receivable_id, :receivable_type | |
| belongs_to :sender, class_name: "User" | |
| belongs_to :receivable, polymorphic: true | |
| end | |
| User Show Page: | |
| <%= form_tag('/notes', method: :post) do %> | |
| <%= label_tag :description, "Post a Note:" %> | |
| <%= text_field_tag :description %> | |
| <%= hidden_field_tag :sender_id, @current_user.id %> | |
| <%= hidden_field_tag :receivable_id, @user.id %> | |
| <%= hidden_field_tag :receivable_type, 'user' %> | |
| <%= submit_tag "Post" %> | |
| <% end %> | |
| <%= @user.received_notes %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment