Coder Social home page Coder Social logo

Comments (6)

gnufied avatar gnufied commented on May 18, 2024

I think the only hope of getting this fixed is, if you can attach a some minimum code that we can run locally and reproduce the problem.

from rails.

larsar avatar larsar commented on May 18, 2024

I created a minimal rails example project with a readme file explaining how to reproduce the problem:

git://github.com/larsar/rails-issue-403.git

from rails.

josevalim avatar josevalim commented on May 18, 2024

Thanks @larsar and @gnufied. Can any of the several contributors now isolate the issue from the minimal rails app to a test case in Rails? This would help us a lot in moving on and fixing the issue. ❤️

from rails.

gnufied avatar gnufied commented on May 18, 2024

On having a look at the sample code, this is not a bug. The problems with code:

  1. Following code is wrong and will not work
has_many :deliveries, :as => :notifiable
has_many :members, :through => :deliveries, :source => :notifiable, :source_type => "Member"

Because when you will say notification.members it will create the join with where condition deliveries.notifiable_id=1 AND deliveries.notifiable_type = 'Notification' . Clearly thats not what you want.

  1. When you are creating deliveries indirectly via notification.members << member , it WILL set notifiable_id and notifiable_type correctly in deliveries table, but AR has no way of knowing that you want to set notification_id in deliveries table as well. It is impossible, you will have to set that yourself.

    In other words, you are expecting too much from Rails here. :)

from rails.

josevalim avatar josevalim commented on May 18, 2024

Ok, closing. Thanks @gnufied.

from rails.

larsar avatar larsar commented on May 18, 2024

Thanks for taking the time to look at this. I'll have to let it sink in and try another solution then. :)

from rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.