Pumpkin1117
Pumpkin1117

Reputation: 13

How to add members to trello board? (using rails app)

I'm using ruby trello gem for my rails app. I need to add members to the created trello board. How can this be realized? I create board like this:

board = Trello::Board.create(
    name: BOARD_NAME,
    description: BOARD_DESC
  )

Upvotes: 0

Views: 102

Answers (1)

anothermh
anothermh

Reputation: 10556

This answer assumes you are using the ruby-trello gem at version 2.2.0.

First, instantiate your board. We will use your example here, but you could also find an existing board:

board = Trello::Board.create(
    name: BOARD_NAME,
    description: BOARD_DESC
  )

Second, instantiate a member. You will need to provide id_or_username for this part:

member = Trello::Member.find(id_or_username)

Third, add the member to the board. You can use any of :admin, :normal, or :observer depending on the permissions the user should have:

board.add_member(member, :normal)

This operation does not require a separate call to save as it does not modify the fields of the board; it calls the API directly.

Upvotes: 1

Related Questions