Study -> has_many Topics -> has_many References
My Model has the following method to access references based on topic ID:
def self.rel_references(topic_id)
Reference.where(:topic_id => topic_id)
end
I am accessing the above in my controller as follows:
@references= Study.rel_references(params[:topic_id])
I need to have a form on the Study model’s Show page to access the references based on the topics the user clicks. (A remote form that loads references based on the topic_id). The way I am trying to do this is:
- form_tag rel_references, :id=>"references_form", :method => 'get' do
= text_field_tag :topic_id, params[:topic_id]
= submit_tag "Get references"
However, I am not being able to access the references in my view. Please help me understand what I may be doing wrong here. I am very new to Rails so I might be missing something here. Thanks!
Removing the deprecated Style block helper – and replacing it with = in my form solved this problem for me. My form Now looks like: