Get $50+ off for Black Friday!

We've moved discussions to Discord

Associate data from discussions to teams instead of being visible for everyone

Borja Soler •
Hi 👋,

I am new here but I was thinking how could I do this better, I have followed the jumpstart pro forum tutorial and now what I would like to do is to set discussions to a team and that only other members of this team can see this discussions and comment. 

I would be like every saas company where each account-team can only see their data and not have share data visible to everyone.

If any of you have done this or have an idea it would be awesome! Thanks! 
Chris Oliver •
Borja Soler just add a belongs_to :team on the Discussion and then make sure that you only query through current_team.discussions when loading the discussions. That's it!
Borja Soler •
Awesome, thank you! 
Borja Soler •
Only thing is that know when I try to do create a discussion it says: 
  • Team must exist

should I add or change something in the discussions_controller.rb?

John Chambers •
Hi  Borja Soler , yes when creating a discussion in discussions_controller.rb set the discussion so it belongs to current_team before save. @discussion.team = current_team

Or maybe like this...

    @discussion = current_team.discussions.new(discussion_params)
    @discussion.save
 
Chris Oliver •
☝️

That's exactly how I do it. I'm actually working on a special scaffold that will do this for you, but Rails scaffolding is turning out to be more confusing than I imagined.
Borja Soler •
Thanks guys! when I add this should I remove the   @discussion = current_user.discussions.new(discussion_params)  or should I write both? 

Also, should I add a new reference to the schema? When I write this I got that team.id does not exist

Borja Soler •
Solved. If anyone needs help with this I can help
Christopher Wavrin •
Borja Soler  Can you post how you solved it? Thanks
Notifications
You’re not receiving notifications from this thread.