I would just do 
``` ruby
def attachment_id
  attachments[:id] if attachments
end
```