I am building a project management app and need some help with how to pass a parameter (I think that is how you say it). Here is what I have going on.
I have a table called "proposals" and "proposals" allow you to create multiple concepts per proposal. I have a table called "concepts" and on each "concept" the user can "comment". The way that I have set this up is to generate a table called concept_comments.
Currently the comments are only associated with the concepts but I would like to display all the comment, across all the concepts, for that particular proposal. I am guessing that his has to do with two things:
- including another line to collect proposal_id when creating a comment.
- Assigning a has_many :concept_comments to the model/proposal.rb file.
- Adding map.resources :proposals, :has_many => :concept_comments.
Not sure if that is correct but that is in my head. Only thing I have done so far is to create a column in my concept_comments table called proposal_id. Here is my concept_comments_controller.rb code for 'create':
def create
@concept = Concept.find(params[:concept_id])
@concept_comment = @concept.concept_comments.create!(params[:concept_comment])
respond_to do |format|
format.html { redirect_to @concept }
format.js
end
end
Not quite sure how to tell it to also collect the proposal_id. Somehow I need to tell it to look at the concept_id that has been passed in, then pull the proposal_id number from the concept table, and pass that to the proposal_id in the concept_comments table.
My thinking is that I can then call on the concept_comments table for all entries that have the proposal_id.
I am not even sure if that makes any sense.