无法查询具有多对多关联的父级-Rails

时间:2018-10-11 19:03:36

标签: ruby-on-rails ruby ruby-on-rails-5

我有3个具有以下结构的模型:

numTickets

我正在尝试编写一个查询,该查询将获取具有与特定位置相关联的父母的发票,但是我提出的查询未返回任何结果。

numTickets

我不确定如何使它正常工作。提前致谢。

1 个答案:

答案 0 :(得分:2)

您忘记使用关联的模型class HomeView(TemplateView): template_name = ('home/home.html') def get(self, request): form = HomeForm() posts = Post.objects.all() args = {'form': form, 'posts': posts} return render(request, self.template_name, args) def post(self, request): form = HomeForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() text = form.cleaned_data['Post'] form = HomeForm() return redirect('home:home') args = {'form': form, 'text': text} return render(request, self.template_name, args) 进行查询。同样,在hfdhdth Posted by john wick on Oct. 11, 2018, 6:56 p.m. vdfgrgrtg Posted by john wick on Oct. 11, 2018, 6:56 p.m. 'btgthh' <------AFTER THIS DOESNT DISPLAY Posted by john wick on Oct. 11, 2018, 6:56 p.m. Posted by john wick on Oct. 11, 2018, 7:13 p.m. Posted by john wick on Oct. 11, 2018, 7:13 p.m. Posted by john wick on Oct. 11, 2018, 7:13 p.m. 参数中,应该使用Hash而不是Array(看起来像是打印错误;否则将是语法错误)。

您的电话是:

join