Félix Landry-Audet

Joined

1,340 Experience
5 Lessons Completed
1 Question Solved

Activity

add_reference :table_name, :column_name, unique: true, foreign_key: true

I think ;)

Posted in How do I create hierarchical data with a model?

Yep thanks I read that. I was confident using awesome-nested_set but just found out closure_tree which seems to have more documentation and more options. I'll try it out.

Thanks!

Posted in Is there a better way to simplify this?

Wouldn't there be an includes(:product) somewhere to avoid too many request to the DB?

Posted in How do I create hierarchical data with a model?

I have found and played with awesome_nested_set which is awesome for real. I was wondering if this is the recommended gem for managing tree data in Rails or if there are any others that would do it. awesome_nested_set is really doing the job however I find it lacks of documentation.

Thanks! :)

Félix

Thanks Chris!

I got it. I used :

validates_uniqueness_of :center_id, scope: :department_id

I have a Center model and a Department model. The linked :through the Local model. However, I want to avoid inserting the same match twice in the Local table.

Do I use a validate statement or there is a different way of telling Rails to raise an error? What would be the best way?

Thanks,

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.