Activity
add_reference :table_name, :column_name, unique: true, foreign_key: true
I think ;)
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?
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,