How to use Rails 4 strong parameters with has_many :through association?

Keep in mind that the name you give to your strong parameters (employees, employee_ids, etc.) is largely irrelevant because it depends on the name you choose to submit. Strong parameters work no “magic” based upon naming conventions. The reason https://gist.github.com/leemcalilly/a71981da605187d46d96 is throwing an “Unpermitted parameter” error on ’employee_ids’ is because it is expecting an array … Read more

SQL many to many select

It’s a straightforward inner join of the tables: SELECT m.name, cp.id_category FROM manufacturer as m INNER JOIN product as p ON m.id_manufacturer = p.id_manufacturer INNER JOIN category_product as cp ON p.id_product = cp.id_product WHERE cp.id_category = ‘some value’

Saving Many to Many relationship data on MVC Create view

Edit: I’ve written this up in 3 blog posts with code part 1 sets up the solution and creates a new user part 2 adds the courses and saves them with the user profile part 3 allows editing and deletion of users and their courses Github source: https://github.com/cbruen1/mvc4-many-to-many I think you’ve strayed from conventions a … Read more

How to define Many-to-Many relationship through Fluent API Entity Framework?

The terms Left and Right in MapLeftKey and MapRightKey in the many-to-many mapping with Fluent API can be misunderstood and I guess your problem is caused by this misunderstanding. One might think that it means they describe the columns that are “left” and “right” in the many-to-many join table. That’s actually the case if you … Read more

a new object was found through a relationship that was not marked cascade PERSIST

What you had likely done is that you created new instance of Article and and some new instance(s) of HeaderField. These instance(s) of HeaderField were then associated with Article. After that trying to persist Article fails, because as error message says, it refers to new objects and relationship is not marked as PERSIST. Additionally according … Read more

Filter ManyToMany box in Django Admin

Ok, this is my solution using above classes. I added a bunch more filters to filter it correctly, but I wanted to make the code readable here. This is exactly what I was looking for, and I found my solution here: http://www.slideshare.net/lincolnloop/customizing-the-django-admin#stats-bottom (slide 50) Add the following to my admin.py: class CustomerForm(forms.ModelForm): def __init__(self, *args, … Read more

error code: 521